Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

898 save app state version 3 #207

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

898 save app state version 3 #207

wants to merge 16 commits into from

Conversation

chlebowa
Copy link
Contributor

@chlebowa chlebowa commented Mar 15, 2024

Companion to insightsengineering/teal#1011
Replaces uses of update*Input with server-side input creation with renderUI.

@chlebowa chlebowa added the core label Mar 15, 2024
@chlebowa chlebowa changed the title use restoreInput in update functions 898 save app state version 3 Mar 15, 2024
@chlebowa chlebowa marked this pull request as ready for review March 15, 2024 15:08
Copy link
Contributor

github-actions bot commented Mar 15, 2024

badge

Code Coverage Summary

Filename                          Stmts    Miss  Cover    Missing
------------------------------  -------  ------  -------  ------------------------------------------------------------------------------
R/all_choices.R                       1       0  100.00%
R/call_utils.R                      156     124  20.51%   19-28, 65, 67, 69, 102-345
R/check_selector.R                   33       0  100.00%
R/choices_labeled.R                 153      27  82.35%   68, 74, 79, 86, 102, 221-225, 229-234, 354-355, 357, 363, 390-397
R/choices_selected.R                 81      11  86.42%   210-238, 275
R/column_functions.R                  3       3  0.00%    15-18
R/data_extract_datanames.R           30       8  73.33%   16-20, 83-85
R/data_extract_filter_module.R       88      43  51.14%   68-81, 100-111, 126-145
R/data_extract_module.R             298      67  77.52%   128, 133, 150, 153-158, 160, 179-182, 212-258, 497, 502, 679, 690-691, 769-774
R/data_extract_read_module.R        137       7  94.89%   34, 39-41, 43, 138, 155
R/data_extract_select_module.R       32      18  43.75%   29-46
R/data_extract_single_module.R       59       1  98.31%   30
R/data_extract_spec.R                32       0  100.00%
R/filter_spec.R                     186       1  99.46%   280
R/format_data_extract.R              16       1  93.75%   48
R/get_dplyr_call.R                  297       0  100.00%
R/get_merge_call.R                  278      29  89.57%   32-38, 49, 215-224, 391, 407-419
R/include_css_js.R                    5       0  100.00%
R/input_checks.R                     11       2  81.82%   17-18
R/merge_data_utils.R                  2       0  100.00%
R/merge_datasets.R                  134       6  95.52%   123, 249-253
R/merge_expression_module.R          60      11  81.67%   161-166, 184, 362-367
R/Queue.R                            23       0  100.00%
R/resolve_delayed.R                  16       4  75.00%   78-81
R/resolve.R                         113      44  61.06%   179-285
R/select_spec.R                      64       8  87.50%   99, 179-186
R/utils.R                            37      24  35.14%   33-46, 174-187
R/zzz.R                               3       3  0.00%    2-4
TOTAL                              2348     442  81.18%

Diff against main

Filename                          Stmts    Miss  Cover
------------------------------  -------  ------  -------
R/data_extract_filter_module.R      -14      -4  -2.79%
R/data_extract_single_module.R       -1      -1  +1.64%
TOTAL                               -15      -5  +0.09%

Results for commit: 6d150fd

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Mar 15, 2024

Unit Tests Summary

  1 files   24 suites   6s ⏱️
189 tests 189 ✅ 0 💤 0 ❌
658 runs  658 ✅ 0 💤 0 ❌

Results for commit 6d150fd.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. Please change filter variable in the encoding panel and see what happens - filter value is not restored properly

pkgload::load_all("teal.modules.general")
pkgload::load_all("teal.transform")
pkgload::load_all("teal")

data <- teal_data()
data <- within(data, {
  require(nestcolor)
  ADSL <- rADSL
})
datanames(data) <- "ADSL"
join_keys(data) <- default_cdisc_join_keys[datanames(data)]

app <- init(
  data = data,
  modules = modules(
    tm_g_association(
      ref = data_extract_spec(
        dataname = "ADSL",
        filter = filter_spec(vars = choices_selected(variable_choices("ADSL"), "SEX")),
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(
            data[["ADSL"]],
            c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
          ),
          selected = "RACE",
          fixed = FALSE
        )
      ),
      vars = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variables:",
          choices = variable_choices(
            data[["ADSL"]],
            c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
          ),
          selected = "BMRKR2",
          multiple = TRUE,
          fixed = FALSE
        )
      ),
      ggplot2_args = ggplot2_args(
        labs = list(subtitle = "Plot generated by Association Module")
      )
    )
  )
)

shinyApp(app$ui, app$server)

vedhav and others added 4 commits March 19, 2024 19:09
Part of the PR #207 

Triggering the reactivity using `observeEvent`

Example to test:

```r
pkgload::load_all("../teal.modules.general")
pkgload::load_all("../teal.transform")
pkgload::load_all("../teal")
pkgload::load_all("../teal.widgets")

data <- teal_data()
data <- within(data, {
  require(nestcolor)
  ADSL <- rADSL
  ADSL$SEX2 <- rADSL$SEX
})
datanames(data) <- "ADSL"
join_keys(data) <- default_cdisc_join_keys[datanames(data)]

app <- init(
  data = data,
  modules = modules(
    tm_g_association(
      ref = data_extract_spec(
        dataname = "ADSL",
        filter = filter_spec(vars = choices_selected(variable_choices("ADSL"), "SEX")),
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(
            data[["ADSL"]],
            c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
          ),
          selected = "RACE",
          fixed = FALSE
        )
      ),
      vars = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variables:",
          choices = variable_choices(
            data[["ADSL"]],
            c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
          ),
          selected = "BMRKR2",
          multiple = TRUE,
          fixed = FALSE
        )
      ),
      ggplot2_args = ggplot2_args(
        labs = list(subtitle = "Plot generated by Association Module")
      )
    )
  )
)

shinyApp(app$ui, app$server)
```
inputId = ns("vals"),
label = filter$label,
choices = vals_options()$choices,
selected = vals_options()$selected,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to rerender when selecting vals

Suggested change
selected = vals_options()$selected,
selected = isolate(vals_options()$selected),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no point in isolating here for two reasons:

  1. This isolate does not isolate, because the reactivity is triggered by vals_options() which is used in the line above vals_options()$choices
  2. The vals_options() is only dependent on input$col and we want the input of vals to render on changes made to input$col.

chlebowa and others added 5 commits March 21, 2024 08:41
Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com>
Signed-off-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants