-
Notifications
You must be signed in to change notification settings - Fork 0
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
Finally implement row review #146
Open
jthompson-arcus
wants to merge
87
commits into
dev
Choose a base branch
from
jt-99-review_by_row_for_reals
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
2d0d704
Add very basic checkbox column to tables
jthompson-arcus d436332
Merge branch 'jt-99-review_by_row' into jt-99-review_by_row_for_reals
jthompson-arcus f56c780
Merge branch 'jt-99-review_by_row' into jt-99-review_by_row_for_reals
jthompson-arcus 67d817f
"Highlight" rows when check status changed
jthompson-arcus 7939b3c
Grab id's for `o_reviewed`
jthompson-arcus e3bb3ed
Add input handler
jthompson-arcus 6e258a2
Capture row index info
jthompson-arcus a42049b
Standardize callbacks and renders
jthompson-arcus 7ba17d9
Add missing observers
jthompson-arcus f0dfcc3
Add study form observers
jthompson-arcus 9f0e4de
Add `anti_join()`s back
jthompson-arcus b703bec
First pass at integration in review module
jthompson-arcus 5fd5747
Fix couple of issues
jthompson-arcus 5956269
Remove row selection
jthompson-arcus d9f49e8
Fix bug on study forms
jthompson-arcus e2b9953
Resolve merge conflict with `jt-99-review_by_row`
jthompson-arcus 2493779
Integrate "form_reviewed" checkbox
jthompson-arcus 0cb8710
Update tables from overall checkbox
jthompson-arcus 2894351
Update `app-feature-1` snapshots
jthompson-arcus b27d95d
Update app-feature-3-002.json
jthompson-arcus 36f843a
Update app_feature_04.md
jthompson-arcus e98afa0
Create custom.js
jthompson-arcus a353f5d
Fix warnings and errors in `mod_common_forms` test
jthompson-arcus 579d80e
Repair part of `mod_review_form` tests
jthompson-arcus a7fda21
Properly handle partially reviewed rows
jthompson-arcus 310eff2
Repair interactivity between overall checkbox and tables
jthompson-arcus 5a78643
Clean up table name
jthompson-arcus 365206d
Update `app_feature_01` JSONs
jthompson-arcus d10e475
Fix issue with setting input for checkbox
jthompson-arcus 1982650
Update `app_feature_03` JSONs
jthompson-arcus 5d45431
Reset review reactiveValues after save
jthompson-arcus 96e795e
Repair study form test
jthompson-arcus f4a71ad
Update test-mod_review_forms.R
jthompson-arcus 54f7f55
Add rudimentary progress bar
jthompson-arcus 2473133
Add transition to progress bar
jthompson-arcus 3123136
Wrap Shiny bindings
jthompson-arcus b987708
Clean up readability of checkbox render function
jthompson-arcus f637dd0
Update `app-feature-01` JSONs
jthompson-arcus 7144bd8
Update `app-feature-02` JSON
jthompson-arcus e6fe7ee
Update `app-feature-03` JSONs
jthompson-arcus d6a2ff9
Add bottom margin to progress bar
jthompson-arcus f0a19e7
Update `mod_study_forms` JSONs
jthompson-arcus bfc864f
Spruce up progress bar output object
jthompson-arcus e9ab76d
Update custom.css
jthompson-arcus c6ef036
Fix "form already reviewed" indicator
jthompson-arcus a36d7cf
Update version
jthompson-arcus a746b2e
Only review selected subject
jthompson-arcus 546b4e4
Save updated status in DOM
jthompson-arcus c07540a
Set `server=FALSE` for the moment
jthompson-arcus 39238a3
Switch back to using server for datatables
jthompson-arcus 70ad863
Improve `update_cbs()`
jthompson-arcus 5c64e08
Resolve issue for partially reviewed rows
jthompson-arcus 02e65df
Return row IDs as well
jthompson-arcus a82bec9
Use `colnames` instead of renaming data frame
jthompson-arcus f3f8247
Remove `plugin = "scrollResize"` from custom datatable
jthompson-arcus 0bb7ee6
Larger rewrite to use datatable proxy objects
jthompson-arcus 05084db
Simplify DT callbacks
jthompson-arcus ebfd724
Update app feature JSONs
jthompson-arcus 33b94f4
Resolve some issues with app feature 4
jthompson-arcus 36a7443
Separate data reload from update
jthompson-arcus fa06ef3
Fix bug with progress bar when datatable is not rendered
jthompson-arcus 689e525
Show 100% completed when no data to review
jthompson-arcus cc34876
Update test-datatable_custom.R
jthompson-arcus 3cde826
Resolve merge conflict with `dev`
jthompson-arcus 83642d8
Fix bug on initialization
jthompson-arcus ee4fdad
Separate `o_reviewed` logic into helper function
jthompson-arcus fa9ded8
Create helper function for review selection UPSERT
jthompson-arcus aa05fbb
Document `o_reviewed` field
jthompson-arcus 5176d1f
Resolve documentation error
jthompson-arcus 2feb93a
Add helper function to update reactive table from user selection
jthompson-arcus 103d282
Move logic to module
jthompson-arcus fa06a00
Add table title back
jthompson-arcus f5fa833
Update documentation
jthompson-arcus 8a200f4
Delete update_tbl_data_from_datatable.Rd
jthompson-arcus dec6f34
Update app feature 01 test JSONs and PNGs
jthompson-arcus db1b0ce
Update app-feature-3-002.json
jthompson-arcus 53eac61
Update app_feature_04.md
jthompson-arcus dbdfc20
Initialize `disabled` element on data creation
jthompson-arcus 7c61998
Update app_feature_04.md
jthompson-arcus b1b514a
Update test-mod_common_forms.R
jthompson-arcus 9481c0e
Update `mod_navigate_review` JSONs
jthompson-arcus 0a96d60
Repair part of study forms tests
jthompson-arcus add5001
Add back table check for common forms
jthompson-arcus 1e94521
Finish repairing study forms tests
jthompson-arcus 10fe949
Update mod_report-001.json
jthompson-arcus 6e03b44
Update `mod_review_form_tbl_server()` documentation
jthompson-arcus 3d14c53
Update global.R
jthompson-arcus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#' Update Review Records | ||
#' | ||
#' Updates the review records data frame when a datatable checkbox is clicked. | ||
#' | ||
#' @param review_records The review records data frame to update. | ||
#' @param review_selection The review selection data frame input from the | ||
#' datatable. | ||
#' @param active_data The active review data frame. | ||
#' | ||
#' @return A data frame containing the updated records data. | ||
#' | ||
#' @details Three main steps are performed: UPSERT, SUBSET, and ANTI-JOIN The | ||
#' UPSERT takes the review selection data frame and upserts it into the review | ||
#' records data frame. (An upsert will insert a record if the unique | ||
#' identifier is not yet present and update a record based on the unique | ||
#' identifier if it already exists.) The SUBSET step removes an empty reviews | ||
#' (partially review rows) and any records not part of the active review (as a | ||
#' precautionary measure). The ANTI-JOIN step removes any records that match | ||
#' the active review (records that will not be changing review status based on | ||
#' user inputs). | ||
#' | ||
#' @noRd | ||
update_review_records <- function(review_records, review_selection, active_data) { | ||
if (is.null(review_records)) | ||
review_records <- data.frame(id = integer(), reviewed = character()) | ||
review_records |> | ||
dplyr::rows_upsert( | ||
review_selection, | ||
by = "id" | ||
) |> | ||
# Remove empty reviews and inactive data IDs | ||
subset(!is.na(reviewed) | !id %in% active_data$id) |> | ||
# Only update records where the review status is being changed | ||
dplyr::anti_join( | ||
active_data, | ||
by = c("id", "reviewed") | ||
) |> | ||
dplyr::arrange(id) | ||
} | ||
|
||
#' Update Server Table from Selection | ||
#' | ||
#' Updates the server table object based on the user selection. | ||
#' | ||
#' @param tbl_data A data frame containing the server table. | ||
#' @param review_selection The review selection data frame input from the | ||
#' datatable. | ||
#' | ||
#' @return A data frame containing the updated table data. | ||
#' | ||
#' @noRd | ||
update_tbl_data_from_datatable <- function(tbl_data, review_selection) { | ||
update_row <- dplyr::distinct(review_selection, reviewed, row_id) | ||
row_ids <- tbl_data$o_reviewed |> lapply(\(x) x[["row_id"]]) |> unlist() | ||
tbl_data[row_ids == update_row$row_id, "o_reviewed"] <- list(list( | ||
modifyList(tbl_data[row_ids == update_row$row_id,]$o_reviewed[[1]], | ||
list(updated = switch(update_row$reviewed, "Yes" = TRUE, "No" = FALSE, NA))) | ||
)) | ||
tbl_data | ||
} | ||
|
||
#' Overall Reviewed Field | ||
#' | ||
#' This field serves as the main communication mechanism between the Shiny | ||
#' session and the DataTable objects in the browser. | ||
#' | ||
#' @format A list with up to five elements: | ||
#' \describe{ | ||
#' \item{reviewed}{A logical indicating the current review status of the table row.} | ||
#' \item{ids}{A vectors containing the `id`s associated with the table row.} | ||
#' \item{row_id}{A numeric value indicating the associated row in the DataTable. (Used to update server data set based on user changes to browser table.)} | ||
#' \item{disabled}{A logical indicating whether the table row is part of the active review.} | ||
#' \item{updated}{A logical indicating whether the user has changed the review status in the DataTable.} | ||
#' } | ||
#' | ||
#' @details The first three elements, `reviewed`, `ids`, and `row_id`, are | ||
#' initialized when the datatable data set is created (via `create_table()` | ||
#' etc.). This occurs whenever there is a change with the review data. The | ||
#' `disabled` element gets updated whenever there is a change in which subject | ||
#' is actively being reviewed. The `updated` field gets changed in one of | ||
#' three events: the subject being reviewed is changed and `updated` gets set | ||
#' to `NULL`, a user changed review status in the DataTable object and | ||
#' `updated` gets set to the user inputted value, and finally when a user | ||
#' changes the overall review status in the sidebar and `updated` gets set to | ||
#' reflect that inputted value. | ||
#' | ||
#' @noRd | ||
# "o_reviewed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, the variable 'update_checkboxes' is only
TRUE
,FALSE
, orNULL
, based on the value ofinput$form_reviewed
. Why is it calledupdate_checkboxes
and notform_reviewed
or something similar, for consistency?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming conventions are a bit in the eye of the beholder, but I named it
update_checkboxes
because that is the action the reactive is meant to trigger. Plus it would be inaccurate to call itform_reviewed
because the value is more tied to changes in the sidebar checkbox, not to the review status of a form.