diff --git a/inst/interface/global.R b/inst/interface/global.R index 9ebd069812b55215455ccca45a32db754a074d5f..94e76f6f1f1ca63059fd2b6ed64820729609e527 100644 --- a/inst/interface/global.R +++ b/inst/interface/global.R @@ -9,6 +9,7 @@ library(shinydashboard) library(rhandsontable) library(shinyFiles) library(shinycssloaders) +library(shinyjs) #### MAIN VARIABLES #### @@ -118,4 +119,5 @@ langHelpMatrix <- c( ) - +# Tab item names +tabItemNames = c("fileTab", "unitTab", "riskTab", "weightTab", "resultTab") diff --git a/inst/interface/server.R b/inst/interface/server.R index 8f44e7d65d02387c70e4336c9f2bdf824693c220..13e9c6e53ae70149b5b8c4c75591b90d32b82183 100644 --- a/inst/interface/server.R +++ b/inst/interface/server.R @@ -251,6 +251,33 @@ server <- function(input, output, session) { }) + + ##### Observer previous/next buttons #### + + observe({ + runjs(" + function getAllElementsWithAttribute(attribute){ + var matchingElements = []; + var allElements = document.getElementsByTagName('*'); + for (var i = 0, n = allElements.length; i < n; i++){ + if (allElements[i].getAttribute(attribute) !== null){ + matchingElements.push(allElements[i]); + } + } + return matchingElements; + }; + + ahref = getAllElementsWithAttribute('data-toggle'); + var tabNames = []; + var tabName = ''; + for (var nr = 0, n = ahref.length; nr < n; nr++){ + tabName = ahref[nr].hash.split('-')[2] + if(tabName != 'Toggle navigation') tabNames.push(tabName) + } + Shiny.onInputChange('tabNames', tabNames); + ") + }) + ##### Observer on layerInfoDF for weight matrix #### observeEvent(rv$layerInfoDF,{ diff --git a/inst/interface/ui.R b/inst/interface/ui.R index 5cc47ddbca367d743326cda830c2af958722a215..17d1c4d9070a67993a0cfca711369c841f849c3e 100644 --- a/inst/interface/ui.R +++ b/inst/interface/ui.R @@ -9,6 +9,9 @@ sidebar <- dashboardSidebar( + useShinyjs(), # Set up shinyjs + + # Radio buttons to select language radioButtons(inputId = "rbLanguage", label = NULL, @@ -82,7 +85,11 @@ body <- dashboardBody( ) - ) + ), + + #Previous/next button + actionButton(inputId ="Previous", label = icon("arrow-left")), + actionButton(inputId ="Next", label = icon("arrow-right")) ), @@ -106,7 +113,11 @@ body <- dashboardBody( plotOutput("unitStatDisplay") - ) + ), + + #Previous/next button + actionButton(inputId ="Previous", label = icon("arrow-left")), + actionButton(inputId ="Next", label = icon("arrow-right")) ), @@ -137,7 +148,11 @@ body <- dashboardBody( ), - actionButton(inputId = "abInvert", label = langDF["ABRiskRasterInvert", indLang]) + actionButton(inputId = "abInvert", label = langDF["ABRiskRasterInvert", indLang]), + + #Previous/next button + actionButton(inputId ="Previous", label = icon("arrow-left")), + actionButton(inputId ="Next", label = icon("arrow-right")) ), @@ -166,9 +181,11 @@ body <- dashboardBody( ) - ) - + ), + #Previous/next button + actionButton(inputId ="Previous", label = icon("arrow-left")), + actionButton(inputId ="Next", label = icon("arrow-right")) ), @@ -202,11 +219,15 @@ body <- dashboardBody( downloadButton(outputId = "exportResultCSV", label = "Export table") - ) + ), + #Previous/next button + actionButton(inputId ="Previous", label = icon("arrow-left")), + actionButton(inputId ="Next", label = icon("arrow-right")) - ) - + + + ) )