Skip to content

Commit

Permalink
Merge pull request #149 from openpharma/jt-fix_dblclick_to_form
Browse files Browse the repository at this point in the history
Fix `dblclick_to_form()`
  • Loading branch information
LDSamson authored Jan 30, 2025
2 parents 50af612 + 93de14d commit 7440824
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clinsight
Title: ClinSight
Version: 0.1.1.9017
Version: 0.1.1.9018
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-6252-7639")),
Expand Down
8 changes: 4 additions & 4 deletions R/fct_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,10 @@ custom_config_path <- function(
dblclick_to_form <- function(bttn_ns) {
DT::JS(
"table.on('dblclick', 'tbody tr', function(t) {",
"t.currentTarget.classList.add('selected');",
"var tblID = $(t.target).closest('.datatables').attr('id')",
"var inputName = tblID + '_rows_selected'",
"Shiny.setInputValue(inputName, t.currentTarget.rowIndex)",
# This processing assumes `server = TRUE`
"var current_index = table.row(this).index();",
"var current_rows = table.ajax.json().DT_rows_current;",
"table.shinyMethods.selectRows(current_rows[current_index]);",
"document.getElementById(", deparse(NS(bttn_ns, "go_to_form")), ").click();",
"})"
)}
Expand Down
2 changes: 1 addition & 1 deletion inst/golem-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
golem_name: clinsight
golem_version: 0.1.1.9017
golem_version: 0.1.1.9018
app_prod: no
user_identification: test_user
study_data: !expr clinsight::clinsightful_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8398,7 +8398,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8663,7 +8663,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8664,7 +8664,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7349,7 +7349,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7463,7 +7463,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8607,7 +8607,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"start_page_1-go_to_patient-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"queries_1-go_to_form-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"queries_1-go_to_form-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"queries_1-go_to_form-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"queries_1-go_to_form-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"queries_1-go_to_form-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"queries_1-go_to_form-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"test-go_to_form-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"test-go_to_form-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"test-go_to_form-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"test-go_to_form-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"serverSide": true,
"processing": true
},
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nt.currentTarget.classList.add('selected');\nvar tblID = $(t.target).closest('.datatables').attr('id')\nvar inputName = tblID + '_rows_selected'\nShiny.setInputValue(inputName, t.currentTarget.rowIndex)\ndocument.getElementById(\n\"test-go_to_form-go_to_form\"\n).click();\n})\n}",
"callback": "function(table) {\ntable.on('dblclick', 'tbody tr', function(t) {\nvar current_index = table.row(this).index();\nvar current_rows = table.ajax.json().DT_rows_current;\ntable.shinyMethods.selectRows(current_rows[current_index]);\ndocument.getElementById(\n\"test-go_to_form-go_to_form\"\n).click();\n})\n}",
"selection": {
"mode": "single",
"selected": null,
Expand Down
9 changes: 8 additions & 1 deletion tests/testthat/test-app_feature_01.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe(
and being logged in as test user,
I expect that I can see the start page,
and that, by double clicking on clicking on 'BEL_04_772' within
the start page table,
the start page table, with and without sorting,
I can see the adverse event page of the selected patient with all
data shown in bold (indicating the need for review),
and that, by clicking on [Study data],
Expand Down Expand Up @@ -48,6 +48,13 @@ describe(
output_names <- names(app$get_values(output = TRUE)$output)
app$expect_values(output = vector_select(output_names, exclude = "visit_figure"))

app$set_inputs(main_tabs = "Start")
app$run_js('$("#start_page_1-overview_table th").filter(function() {return $(this).text() == "Status"}).closest("th").trigger("click")')
app$run_js('$("#start_page_1-overview_table td").filter(function() {return $(this).text() == "BEL_04_772"}).closest("tr").trigger("dblclick")')
app$wait_for_idle()
expect_equal(app$get_value(input = "main_tabs"), "Common events")
expect_equal(app$get_text("#navigate_participants_1-subject_info .value-box-title"), "BEL_04_772")

app$set_inputs(main_tabs = "Study data")
app$wait_for_idle()
output_names <- names(app$get_values(output = TRUE)$output)
Expand Down

0 comments on commit 7440824

Please sign in to comment.