-
Notifications
You must be signed in to change notification settings - Fork 226
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
(fix)O3-3046: Allow sorting vitals, biometrics and conditions rows based on different sort functions #1779
Conversation
Size Change: -177 kB (-2%) Total Size: 11.1 MB
ℹ️ View Unchanged
|
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.
LGTM, but I'm unclear about why the conditions stuff is part of this PR?
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.
A few concerns though it mostly looks good to me. There's a bunch of failing tests. Likely to do with the default sort order.
sortFunc: (valueA: ConditionTableRow, valueB: ConditionTableRow) => number; | ||
} | ||
|
||
export function useConditionsSorting(tableHeaders: Array<ConditionTableHeader>, tableRows: Array<ConditionTableRow>) { |
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.
Would something like useSortedConditionTableRows
describe this hook better?
{ | ||
key: 'muac', | ||
key: 'dateRender', |
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.
What's the rationale behind the Render
suffix?
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.
There are 2 kinds of data for a column (say date
column):
date
, which is the ISO stringdateRender
, which is the formatted version of the pt.1 date.
Now, if we see, the user/ datatable sees the dateRender
on the screen, but we want to sort the column based on the date
value, hence I added the "Render" suffix to differentiate and keep the original value intact.
The sortFunc
of the header will be using the date
for comparison, and the DataTable will be using dateRender
for rendering data in the column.
{ | ||
key: 'temperature', | ||
key: 'dateRender', |
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.
Is the idea to repackage this logic as a custom hook, similar to what you did with conditions above?
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.
Yes @denniskigen, I'll move this hook inside the framework such that all the data tables can use this similar implementation.
The new need from the developer will be to add the sortFunc
for every header in the tableHeaders.
If you have a better idea than this, I'm all open to hear it.
Thansk!
The failing vitals and biometrics tests are likely due to a change in the default sort order behaviour. |
Fixed the failing tests @denniskigen |
Requirements
Summary
This PR adds custom sorting functions for every column in the vitals, biometrics and conditions table.
Screenshots
Screen.Recording.2024-04-08.at.15.50.01.mov
Related Issue
https://issues.openmrs.org/browse/O3-3046
Other
None