-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui_solutionResultsModal.R
146 lines (144 loc) · 4.96 KB
/
ui_solutionResultsModal.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#' @include internal.R widget_solutionResults_ui.R
NULL
#' Solution results modal
#'
#' Constructs a modal for displaying solution results.
#'
#' @param id `character` identifier for the modal.
#'
#' @param trigger `character` identifier for the modal trigger.
#' See [shinyBS::bsModal] for further details.
#'
#' @return A `shiny.tag` object with the modal
#'
#' @examples
#' \dontrun{
#' # run Shiny app to demo the sidebar pane
#' if (interactive()) {
#' runExample("solutionResultsModal")
#' }
#' }
#'
#' @export
solutionResultsModal <- function(id, trigger) {
# create modal
out <-
htmltools::tags$div(
# script to style modal backdrop
htmltools::tags$script(htmltools::HTML(paste0(
"$('#", id, "').on('show.bs.modal', function() {",
" setTimeout(function() {",
" $('#", id, "').appendTo('body');",
"$('.modal-backdrop').addClass('sbs-modal-backdrop');",
"})});"
))),
class = "solution-results-modal modal sbs-modal fade",
id = id,
tabindex = "-1",
`data-sbs-trigger` = trigger,
# modal content
htmltools::tags$div(
class = "modal-dialog modal-xl",
htmltools::tags$div(
class = "modal-content",
## header
htmltools::tags$div(
class = "modal-header",
### close button
htmltools::tags$button(
type = "button",
class = "close",
`data-dismiss` = "modal",
htmltools::tags$span(htmltools::HTML("×"))
),
htmltools::tags$div(
class = "modal-header-content",
### solution select container
htmltools::tags$div(
class = "select-container",
horizontalPickerInput(
inputId = paste0(id, "_select"),
choices = "NA",
label = "Solution:",
multiple = FALSE,
options = list(`container` = "body")
)
),
### radio button container
htmltools::tags$div(
class = "radio-container",
shinyWidgets::radioGroupButtons(
inputId = paste0(id, "_radio"),
label = NULL,
choices = c(
`<i class='fa fa-chart-line'></i>Summary` = "summary",
`<i class='fa fa-star'></i>Themes` = "themes",
`<i class='fa fa-weight-hanging'></i>Weights` = "weights",
`<i class='fa fa-lock'></i>Includes` = "includes",
`<i class='fa fa-ban'></i>Excludes` = "excludes"
),
justified = FALSE,
size = "normal"
),
),
## download buttons
shiny::downloadButton(
outputId = "summary_results_button",
label = "Download summary results",
class = "btn-sm"
),
shiny::downloadButton(
outputId = "theme_results_button",
label = "Download theme results",
class = "btn-sm"
),
shiny::downloadButton(
outputId = "weight_results_button",
label = "Download weight results",
class = "btn-sm"
),
shiny::downloadButton(
outputId = "include_results_button",
label = "Download include results",
class = "btn-sm"
),
shiny::downloadButton(
outputId = "exclude_results_button",
label = "Download exclude results",
class = "btn-sm"
)
)
),
## body
htmltools::tags$div(
class = "modal-body",
shiny::conditionalPanel(
condition = paste0("input.", id, "_radio == 'summary'"),
DT::DTOutput(outputId = paste0(id, "_summary_table"))
),
shiny::conditionalPanel(
condition = paste0("input.", id, "_radio == 'themes'"),
DT::DTOutput(outputId = paste0(id, "_themes_table"))
),
shiny::conditionalPanel(
condition = paste0("input.", id, "_radio == 'weights'"),
DT::DTOutput(outputId = paste0(id, "_weights_table"))
),
shiny::conditionalPanel(
condition = paste0("input.", id, "_radio == 'includes'"),
DT::DTOutput(outputId = paste0(id, "_includes_table"))
),
shiny::conditionalPanel(
condition = paste0("input.", id, "_radio == 'excludes'"),
DT::DTOutput(outputId = paste0(id, "_excludes_table"))
)
)
)
)
)
# attach dependencies
htmltools::attachDependencies(
out,
htmltools::htmlDependencies(shinyBS::bsModal("x", "y", "z"))
)
}