SNT-225 Users can work on a scenario by filtering on a specific "parent OU"#180
SNT-225 Users can work on a scenario by filtering on a specific "parent OU"#180
Conversation
bramj
left a comment
There was a problem hiding this comment.
General comment: I think this PR stands up fairly well on its own, but will come together better with https://bluesquare.atlassian.net/browse/SNT-254 (showing the province boundaries)
I propose to better handle the visualization of this in a PR for that ticket.
| }, [bounds, boundsOptions, map]); | ||
|
|
||
| return null; | ||
| }; |
There was a problem hiding this comment.
@Bewi I'll be honest: My frontend skills are not sufficient to know if this is the correct approach. It works well, and it feels like a clean pattern, but would be great if you can verify.
There was a problem hiding this comment.
Looks good to me, I would only move FitBounds on its own file and type the InvalidateOnResize to be a FC
| // ancestors of the districts/zones de sante, so we can show these borders on the | ||
| // map. | ||
| // I think this will require us to configure somewhere the OU type that we're | ||
| // assigning interventions on. |
There was a problem hiding this comment.
Let's of complexity here can be simplified when we have a config for the country that states which OU type we actually want to show, instead of relying on the "valid OUs with geoms".
| const currDepth = | ||
| (curr.original as { depth?: number | null }).depth ?? | ||
| Infinity; | ||
| return currDepth < prevDepth ? curr : prev; |
There was a problem hiding this comment.
Same here, this is ugly, can can be simplified, but out of scope for this PR I'd say
| }; | ||
| if (orgUnitParentId) { | ||
| params.orgUnitParentId = orgUnitParentId; | ||
| } |
There was a problem hiding this comment.
I had to go with backend filtering since the OU payload doesn't contain enough data about the whole ancestor chain (e.g. for BFA, you probably want to filter on Region instead of Province, which is 2 levels up from the district)
Bewi
left a comment
There was a problem hiding this comment.
Overall it looks good.
I do wonder few things:
- When country OU type is selected, do we really want to display the org unit selector ?
- Overall it feels super complex, I suggest we have another task to try to think of a simplified approach.
- Budgeting is acting weird on my side, the breakdown chart seems broken
| * Place this inside a `<MapContainer>` to handle dynamic layout changes | ||
| * (e.g. sidebar open/close) that Leaflet can't detect on its own. | ||
| */ | ||
| export const InvalidateOnResize = () => { |
There was a problem hiding this comment.
I would type this as a FC as well to know exactly what it is, I thought it was an utility function at first :D
| }, [bounds, boundsOptions, map]); | ||
|
|
||
| return null; | ||
| }; |
There was a problem hiding this comment.
Looks good to me, I would only move FitBounds on its own file and type the InvalidateOnResize to be a FC
| {formatMessage(MESSAGES.total)} :{' '} | ||
| {formatBigNumber(totalCost)} | ||
| </Typography> | ||
| <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}> |
There was a problem hiding this comment.
SX should be in a style object, it makes it easier to track and reduces html complexity
| }, [orgUnits]); | ||
|
|
||
| // Filter org unit types to show only types with depth <= parentTypeDepth | ||
| // Note: The original object from API includes depth, but OriginalOrgUnitType type doesn't declare it |
There was a problem hiding this comment.
We could just add it and make it nullable on the model ?
There was a problem hiding this comment.
I remember now: I wanted to avoid having to add something to such a basic type in IASO for fear of breaking something
js/src/domains/planning/index.tsx
Outdated
| [params, redirectToReplace], | ||
| ); | ||
|
|
||
| const handleToggleSidebar = useCallback(() => { |
There was a problem hiding this comment.
Feels like this useCallback is pointless, could use setIsSidebarOpen directly
| </Typography> | ||
| </MenuItem> | ||
| )} | ||
| <MenuItem value={0}> |
There was a problem hiding this comment.
I am not sure about this, don't like having an intervention selector if there is only one assigned to all org units.
Even if the user has stripped down his view.
I am guessing that you changed this because when we select a parent OU, we might reach a point when we only have one intervention assigned but for the country we might have mulitple ?
There was a problem hiding this comment.
Actually, I changed that one because it produced a ton of MUI warnings in the console, and it felt like an unnecessary check. Here is the commit: a101190, we can always revert it
There was a problem hiding this comment.
I'll revert for now 👍
| </MenuItem> | ||
| )} | ||
| {showAllOption && sortedInterventions.length > 1 && ( | ||
| {showAllOption && ( |
There was a problem hiding this comment.
Same here, not sure we still want to display this if there is only one intervention
I agree, but the OU type names are not fixed, so we'd need to be smart about it. In this implementation, I take all ancestors that are higher than the OU level at which we do intervention planning. We don't know beforehand how many ancestors there are, and what they're named. Not sure how to work around that 🤔
I was also surprised at how complex this all turned out to be 😅 .
That's a bug, I'll check this. |
6534452 to
2af2b6e
Compare
|
@Bewi Okay I fixed most of your review comments, thanks for them 🙏 I also had a look at the complexity again, and I agree, it hurts the head. One of the main sources for complexity is the automatic determining of the OU level at which we do intervention planning. I feel like I need a "country account configuration", like the
Perhaps I can use the IASO |
3a07ac1 to
4dbf009
Compare
51a3bd4 to
83a6d53
Compare
3450c5c to
f24a915
Compare
|
Finally! I'm happy with the implementation. I'll do a rebase after getting this one merged #195 and then it's good to go I think. I made big simplifications mainly on:
|
or when sidebar is expanded/collapsed.
to InvalidateOnResize component.
- Use the `JsonDataStore` to determine the filtering levels - Massively simplify the component - Improve the UX: showing "National" as default
f24a915 to
a803535
Compare

Changes
Related JIRA tickets
https://bluesquare.atlassian.net/browse/SNT-225
Print screen / video
filter-by-ou-parent-2026-02-02_11.08.17.webm
How to test