Skip to content

Commit

Permalink
feat: handle deletion of samples when contrasts are already uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromiguelm committed Mar 1, 2024
1 parent bd0e001 commit c83cf2c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
3 changes: 0 additions & 3 deletions components/00SourceAll.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ if(!file.exists('00SourceAll.R')) {
source('board.upload/R/upload_module_makecontrast.R',encoding='UTF-8')
source('board.upload/R/upload_module_outliers.R',encoding='UTF-8')
source('board.upload/R/upload_module_preview.R',encoding='UTF-8')
source('board.upload/R/upload_plot_contraststats.R',encoding='UTF-8')
source('board.upload/R/upload_plot_countstats.R',encoding='UTF-8')
source('board.upload/R/upload_plot_pcaplot.R',encoding='UTF-8')
source('board.upload/R/upload_plot_phenostats.R',encoding='UTF-8')
source('board.upload/R/upload_server.R',encoding='UTF-8')
source('board.upload/R/upload_ui.R',encoding='UTF-8')
source('board.upload/R/upload_utils.R',encoding='UTF-8')
Expand Down
29 changes: 26 additions & 3 deletions components/board.upload/R/upload_module_preview.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ upload_table_preview_counts_server <- function(
showCancelButton = TRUE,
closeOnEsc = FALSE,
callbackR = delete_all_files_counts,
confirmButtonText = "Yes, remove counts",
cancelButtonText = "No, cancel"
confirmButtonText = "Yes, remove all files.",
cancelButtonText = "No, cancel deletion."
)} else {
uploaded$counts.csv <- NULL
}
Expand Down Expand Up @@ -360,7 +360,30 @@ upload_table_preview_samples_server <- function(
})

observeEvent(input$remove_samples, {
uploaded$samples.csv <- NULL

delete_all_files_samples <- function(value) {
if(input$alert_delete_samples){
uploaded$samples.csv <- NULL
uploaded$contrasts.csv <- NULL
}
}

# if samples is not null, warn user that it will be deleted
if(!is.null(uploaded$contrasts.csv)){
# make a pop up and give user option to delete all files or just counts
shinyalert::shinyalert(
inputId = "alert_delete_samples",
title = "Warning",
text = "Removing samples will also remove contrasts. Do you want to proceed?",
type = "warning",
showCancelButton = TRUE,
closeOnEsc = FALSE,
callbackR = delete_all_files_samples,
confirmButtonText = "Yes, remove samples and contrasts.",
cancelButtonText = "No, cancel deletion."
)} else {
uploaded$counts.csv <- NULL
}
})

observeEvent(input$load_example, {
Expand Down
10 changes: 0 additions & 10 deletions components/board.upload/R/upload_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,6 @@ UploadBoard <- function(id,

## Check if samples.csv exists before uploading contrast.csv
cc <- checked_samples()
if (!is.null(checked) && is.null(cc$matrix)) {
status <- "ERROR: please upload samples file first."
checked <- NULL
# pop up telling the user to upload samples.csv first
shinyalert::shinyalert(
title = "Samples.csv file missing",
text = "Please upload the samples.csv file first.",
type = "error"
)
}

## -------------- max contrast check ------------------
MAXCONTRASTS <- as.integer(auth$options$MAX_COMPARISONS)
Expand Down

0 comments on commit c83cf2c

Please sign in to comment.