From b44f508bb422e90a39373a02187c499628ec027a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu>
Date: Tue, 10 Mar 2020 19:35:33 +0100
Subject: [PATCH] Restoring config now knows how to handle tags

---
 R/shinyUI.R | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/R/shinyUI.R b/R/shinyUI.R
index 89508bc..a6eefb6 100644
--- a/R/shinyUI.R
+++ b/R/shinyUI.R
@@ -723,6 +723,16 @@ mk_shinyscreen <- function(projDir=getwd(),
         NULL
     }
 
+    txt2tags<-function(txt){
+        ## Turns a string into tags
+        x <- if (shiny::isTruthy(txt)) {
+                 trimws(unlist(strsplit(txt, ",")))
+             } else list()
+        
+        
+        as.list(c("unspecified",x))
+    }
+
 
     server <- function(input,output,session) {
 
@@ -782,12 +792,7 @@ mk_shinyscreen <- function(projDir=getwd(),
         get_all_tags<-shiny::reactive({
             ## Returns all tags from the input box.
             tagsInp<-input$tagsInp
-            x <- if (shiny::isTruthy(tagsInp)) {
-                     trimws(unlist(strsplit(tagsInp, ",")))
-                 } else list()
-
-            
-            as.list(c("unspecified",x))
+            txt2tags(tagsInp)
         })
 
 
@@ -999,6 +1004,17 @@ mk_shinyscreen <- function(projDir=getwd(),
                 for (nm in REST_TAB) {
                     rvTab[[nm]]<-sav$tab[[nm]]
                 }
+
+                ## Restore tags.
+                mzmlTags <- levels(rvTab$mzml$tag)
+                currTags <- txt2tags(sav$input[["tagsInp"]])
+                z <- unique(c(currTags, mzmlTags))
+                z <- z[z != 'unspecified']
+                alltags <- do.call(paste,c(as.list(z),sep=','))
+                shiny::updateTextInput(session=session,
+                                       inputId="tagsInp",
+                                       value=alltags)
+                
             }
         })
 
@@ -1598,6 +1614,7 @@ mk_shinyscreen <- function(projDir=getwd(),
         {
             fchoice<-shinyFiles::parseFilePaths(root=volumes,input$mzMLB)
             paths<-fchoice[["datapath"]]
+            shiny::validate(need(rvTab$mzml,"There is no skeleton table. Sets? Tags?"))
             rvTab$mzml<-add_mzML_files(rvTab$mzml,paths)
         })
         
-- 
GitLab