-
Notifications
You must be signed in to change notification settings - Fork 15
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(OrganisationUnitTree): deduplicate orgunit roots #1625
base: master
Are you sure you want to change the base?
Conversation
🚀 Deployed on https://pr-1625--dhis2-ui.netlify.app |
* @returns {Array} - A filtered list of the minimum root units | ||
*/ | ||
export const deduplicateOrgUnitRoots = (unitsWithLevel) => { | ||
const sorted = unitsWithLevel.sort((a, b) => a.level - b.level) |
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.
Note that we could use the "path" instead of level here - because path consists of the ids, and every id has the same length. But it's more semantically correct to use the level
, even if I had to add another field to the request.
Implements LIBS-702
Description
In OrganisationUnitTree component, you can pass roots that are descendants of other roots, e.g. if you pass <OrganisationUnitTree roots=[OrgUnitA, OrgUnitB, OrgUnitC] /> where OrgUnitB is a descendant of OrgUnitA and where OrgUnitC is a descendant of OrgUnitA, then you presumably want to display only OrgUnitA as a root (e.g. the deduplicated root).
This PR implements a function
deduplicateOrgUnitRoots
that will check the levels of the units, and only return the true "minimal roots" - and ignore rendering input IDs as roots, if another root contains it.Know issues
in
-filter. It quite wasteful currently.Checklist
All points above should be relevant for feature PRs. For bugfixes, some points might not be relevant. In that case, just check them anyway to signal the work is done.