Skip to content

Commit

Permalink
Add missing observers
Browse files Browse the repository at this point in the history
  • Loading branch information
jthompson-arcus committed Nov 25, 2024
1 parent a42049b commit 7ba17d9
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions R/mod_common_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ mod_common_forms_server <- function(
dplyr::arrange(id)
})

observeEvent(input$SAE_table_review_selection, {
session$userData$review_records[[form]] <-
dplyr::rows_upsert(
session$userData$review_records[[form]],
input$SAE_table_review_selection,
by = "id"
) |>
dplyr::arrange(id)
})

output[["common_form_table"]] <- DT::renderDT({
df <- data_active()
if(form == "Adverse events") {
Expand All @@ -178,37 +188,12 @@ mod_common_forms_server <- function(
rownames= FALSE,
title = form,
escape = FALSE,
callback = DT::JS(
"table.on('click', 'input[type=\"checkbox\"]', function(){",
"var tblId = $(this).closest('.datatables').attr('id');",
"var cell = table.cell($(this).closest('td'));",
"var rowIdx = table.row($(this).closest('tr')).index();",
"var ids = cell.data().ids;",
"var review = $(this).is(':checked');",
"var info = {review: review, ids: ids, row: tblId + '_row_' + rowIdx};",
"Shiny.setInputValue(tblId + '_review_selection:CS.reviewInfo', info);",
"})"
),
callback = checkbox_callback,
options = list(
columnDefs = list(list(
targets = 0,
render = DT::JS(
"function(data, type, row, meta) {",
"var reviewed = data.reviewed;",
"return `<input type='checkbox' class='${reviewed == null ? 'indeterminate' : reviewed ? 'checked' : 'unchecked'}' ${reviewed ? 'checked' : ''} ${reviewed == null ? 'onclick=\"ts(this)\"' : ''}/>`;",
"}"
)
render = checkbox_render
)),
createdRow = DT::JS(
"function(row, data, dataIndex) {",
"if (data[0] == null) {",
"let cb = row.cells[0].getElementsByTagName('input')[0]",
"cb.indeterminate = cb.readOnly = true;",
"}",
"}"
)
createdRow = checkbox_create_callback
))
})
Expand Down

0 comments on commit 7ba17d9

Please sign in to comment.