-
Notifications
You must be signed in to change notification settings - Fork 4
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: handle options with non-unique codes across optionsets (DHIS2-15771) #426
Conversation
🚀 Deployed on https://pr-426--dhis2-line-listing.netlify.app |
Passing run #2004 ↗︎
Details:
Review all test suite changes for PR #426 ↗︎ |
e4166aa
to
c49fb2e
Compare
c49fb2e
to
015d511
Compare
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.
findOptionSetItem
could be written as a single line, but I see that splitting it up increases readability. However, I'd argue that some parts are a bit unnecessary/too explicit right now, which actually decreases readability.
Needs Cypress tests |
Added. |
5375f65
to
de978ee
Compare
## [100.10.5](v100.10.4...v100.10.5) (2023-11-23) ### Bug Fixes * handle options with non-unique codes across optionsets (DHIS2-15771) ([#426](#426)) ([37e3e69](37e3e69))
🎉 This PR is included in version 100.10.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This requires a backend fix.
Fixes DHIS2-15771
Fixes DHIS2-16181
Requires DHIS2-15775
Key features
Description
Options for different option sets can use the same
code
, which is what is returned in the rows in the analytics response.The previous way of looking up the label to display in the table simply tried to find a metadata object whom
code
matches the value for the option set in the response's rows.This cause to display the wrong label when different option sets are displayed at the same time and happen to use the same
code
.Refer to the screenshots below.
The 3 columns are 3 different option sets, but they all use the same
code
(1) for their option.The first matching
code
found in metadata items (in the analytics response) was always used regardless of the option set.The fix is to look in metadata first for the
optionSet
, and find the matching option bycode
within the listedoptions
.Then the option's id is used to lookup the option itself in metadata and from there the
name
is extracted and used in the table.The same logic needs to be applied when looking up the name to display in the layout chip tooltip for dimensions with option set where there is a specific selection (not all values).
We also need to add the metadata for the options when loading a saved visualization.
The reason here is that the table might not have all the values there are selected for the option set, and in that case the metadata from the analytics response is partial.
While working on this I realised that we don't really need to store the metadata for the single options of an option set.
Since we need them in the
options
object in the option set metadata anyway for the lookup, we can have thename
in there as well and skip one lookup.TODO
Known issues
table.cy.js
is now failing due to this change. This is not a regression, it should be working once the backend fix is available.Screenshots
Table before:
Table after:
Tooltip before:
Notice the names for the selected options are wrong when a different dimension with option set has also a selection and the
code
used is the same:In this example, this selection was made first:
Tooltip after:
Notice the Pain medication dimension has 5 options selected, but the tooltip for pre-eclampsia is correct: