@@ -369,6 +369,7 @@ FilterState <- R6::R6Class( # nolint
369369 moduleServer(
370370 id = id ,
371371 function (input , output , session ) {
372+ private $ server_summary(" summary" )
372373 private $ server_inputs(" inputs" )
373374 reactive(input $ remove ) # back to parent to remove self
374375 }
@@ -381,39 +382,17 @@ FilterState <- R6::R6Class( # nolint
381382 # ' @param id (`character(1)`)\cr
382383 # ' shiny element (module instance) id;
383384 # ' the UI for this class contains simple message stating that it is not supported
384- # '
385- ui = function (id ) {
385+ # ' @param parent_id (`character(1)`) id of the FilterStates card container
386+ ui = function (id , parent_id ) {
386387 ns <- NS(id )
387- fluidPage(
388- include_css_files(pattern = " filter-panel" ),
389- theme = get_teal_bs_theme(),
390- fluidRow(
391- column(
392- width = 10 ,
393- class = " no-left-right-padding" ,
394- tags $ div(
395- tags $ span(private $ varname ,
396- class = " filter_panel_varname"
397- ),
398- if (checkmate :: test_character(self $ get_varlabel(), min.len = 1 ) &&
399- tolower(private $ varname ) != tolower(self $ get_varlabel())) {
400- tags $ span(self $ get_varlabel(), class = " filter_panel_varlabel" )
401- }
402- )
403- ),
404- column(
405- width = 2 ,
406- class = " no-left-right-padding" ,
407- actionLink(
408- ns(" remove" ),
409- label = " " ,
410- icon = icon(" circle-xmark" , lib = " font-awesome" ),
411- class = " remove pull-right"
412- )
413- )
414- ),
415- private $ ui_inputs(ns(" inputs" ))
416- )
388+
389+ theme <- getOption(" teal.bs_theme" )
390+
391+ if (is.null(theme )) {
392+ private $ ui_bs3(id , parent_id )
393+ } else {
394+ private $ ui_bs45(id , parent_id )
395+ }
417396 }
418397 ),
419398
@@ -538,7 +517,13 @@ FilterState <- R6::R6Class( # nolint
538517 },
539518
540519 # shiny modules -----
541- # module with inputs
520+ ui_summary = function (id ) {
521+ stop(" abstract class" )
522+ },
523+ server_summary = function (id ) {
524+ stop(" abstract class" )
525+ },
526+ # ' module with inputs
542527 ui_inputs = function (id ) {
543528 stop(" abstract class" )
544529 },
@@ -622,6 +607,98 @@ FilterState <- R6::R6Class( # nolint
622607 )
623608 invisible (NULL )
624609 })
610+ },
611+ # @description
612+ # Filter card UI for Bootstrap 3.
613+ #
614+ # @param id (`character(1)`) Id for the containing HTML element.
615+ # @param parent_id (`character(1)`) id of the FilterStates card container
616+ ui_bs3 = function (id , parent_id ) {
617+ ns <- NS(id )
618+
619+ tags $ div(
620+ id = id ,
621+ class = " panel panel-default" ,
622+ tags $ div(
623+ class = " panel-heading" ,
624+ tags $ div(
625+ class = " panel-title" ,
626+ tags $ a(
627+ class = " accordion-toggle" ,
628+ `data-toggle` = " collapse" ,
629+ `data-parent` = paste0(" #" , parent_id ),
630+ href = paste0(" #" , ns(" body" )),
631+ tags $ span(tags $ strong(self $ get_varname())),
632+ if (length(self $ get_varlabel())) {
633+ tags $ span(self $ get_varlabel(), class = " filter-card-varlabel" )
634+ } else {
635+ NULL
636+ }
637+ ),
638+ actionLink(
639+ inputId = ns(" remove" ),
640+ label = icon(" circle-xmark" , lib = " font-awesome" ),
641+ class = " filter-card-remove"
642+ )
643+ ),
644+ private $ ui_summary(ns(" summary" ))
645+ ),
646+ tags $ div(
647+ id = ns(" body" ),
648+ class = " panel-collapse collapse out" ,
649+ tags $ div(
650+ class = " panel-body" ,
651+ private $ ui_inputs(ns(" inputs" ))
652+ )
653+ )
654+ )
655+ },
656+ # @description
657+ # Filter card ui for Bootstrap 4 and 5.
658+ #
659+ # @param id (`character(1)`) Id for the containing HTML element.
660+ # @param parent_id (`character(1)`) id of the FilterStates card container
661+ ui_bs45 = function (id , parent_id ) {
662+ ns <- NS(id )
663+
664+ tags $ div(
665+ id = id ,
666+ class = " card" ,
667+ tags $ div(
668+ class = " card-header" ,
669+ tags $ div(
670+ class = " card-title" ,
671+ tags $ a(
672+ class = " accordion-toggle" ,
673+ `data-toggle` = " collapse" ,
674+ `data-bs-toggle` = " collapse" ,
675+ href = paste0(" #" , ns(" body" )),
676+ tags $ span(tags $ strong(self $ get_varname())),
677+ if (length(self $ get_varlabel())) {
678+ tags $ span(self $ get_varlabel(), class = " filter-card-varlabel" )
679+ } else {
680+ NULL
681+ }
682+ ),
683+ actionLink(
684+ inputId = ns(" remove" ),
685+ label = icon(" circle-xmark" , lib = " font-awesome" ),
686+ class = " filter-card-remove"
687+ )
688+ ),
689+ private $ ui_summary(ns(" summary" ))
690+ ),
691+ tags $ div(
692+ id = ns(" body" ),
693+ class = " collapse out" ,
694+ `data-parent` = paste0(" #" , parent_id ),
695+ `data-bs-parent` = paste0(" #" , parent_id ),
696+ tags $ div(
697+ class = " card-body" ,
698+ private $ ui_inputs(ns(" inputs" ))
699+ )
700+ )
701+ )
625702 }
626703 )
627704)
0 commit comments