Skip to content

Commit 829488b

Browse files
authored
Merge pull request #102 from The-Strategy-Unit/59-bookmarks
Add bookmarking functionality and button
2 parents be66f1f + 4f5e687 commit 829488b

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

R/app_ui.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ app_ui <- function(request) {
9595
sidebar = bslib::sidebar(
9696
bslib::accordion(
9797
id = "sidebar_accordion",
98-
9998
open = FALSE,
10099
multiple = TRUE,
101100
bslib::accordion_panel(
@@ -109,6 +108,11 @@ app_ui <- function(request) {
109108
icon = bsicons::bs_icon("hospital"),
110109
mod_select_strategy_ui("mod_select_strategy")
111110
)
111+
),
112+
shiny::bookmarkButton(
113+
label = "Bookmark",
114+
title = "Bookmark your selections and get a URL for sharing",
115+
icon = bsicons::bs_icon("bookmark"),
112116
)
113117
)
114118
)

R/mod_select_provider.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ mod_select_provider_server <- function(id, selected_geography) {
5050
)
5151
})
5252

53+
shiny::onRestored(function(state) {
54+
# Enforce loading of selection when restoring from a bookmark
55+
shiny::updateSelectInput(
56+
session,
57+
"provider_select",
58+
selected = state$input$provider_select
59+
)
60+
})
61+
5362
shiny::reactive(input$provider_select)
5463
})
5564
}

R/mod_select_strategy.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ mod_select_strategy_server <- function(id) {
8787
)
8888
})
8989

90+
shiny::onRestored(function(state) {
91+
# Enforce loading of selection when restoring from a bookmark
92+
shiny::updateSelectInput(
93+
session,
94+
"strategy_select",
95+
selected = state$input$strategy_select
96+
)
97+
})
98+
9099
shiny::reactive(input$strategy_select)
91100
})
92101
}

inst/app/text/info-interface.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
You can hover over the **information symbol** <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="bi bi-info-circle " style="height:1em;width:1em;fill:currentColor;vertical-align:-0.125em;" aria-hidden="true" role="img" ><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path> <path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"></path></svg> for further details.
22

3+
Click the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmark" viewBox="0 0 16 16"><path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.777.416L8 13.101l-5.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v12.566l4.723-2.482a.5.5 0 0 1 .554 0L13 14.566V2a1 1 0 0 0-1-1z"/></svg> **Bookmark** button to save your selections and get a shareable URL so you can return to the app with these choices loaded.
4+
35
To maximise space, you can click the:
46

57
* <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-expand" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M3.646 9.146a.5.5 0 0 1 .708 0L8 12.793l3.646-3.647a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 0-.708m0-2.292a.5.5 0 0 0 .708 0L8 3.207l3.646 3.647a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 0 0 0 .708"/>

0 commit comments

Comments
 (0)