-
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
[Publisher][Agency Settings] Add new agency definition section for court and supervision sectors #1594
[Publisher][Agency Settings] Add new agency definition section for court and supervision sectors #1594
Conversation
Hi @nichelle-hall! Please test this feature and tell me your thoughts about my changes! Also, I have two questions:
but in issue description there is another statement:
Could you please explain to me if my understanding based on my implementation is right or do I need to change something? If the latter, could you maybe tell me in more details about it?
Thank you in advance! |
Hi Ilya! Sorry it took me a few days to get back to you - I was out on Friday. We actually had a meeting today and it looks like CSG is still ironing out what they want from this feature. We're gonna wait until Mahmoud comes back to iron it out some more. He'll be back on Wednesday. Do you have other tickets to work on in the meantime? |
Oh, okay, I see!
Sure, I have plenty! |
Hi @nasaownsky! I'll do a deeper review of the code next week, but just wanted to answer your questions:
Sorry, this was a bad explanation on my part. I think you implemented it how the ticket was described, but if I could go back in time, I'd remove that note in the ticket, and clarify that they should be separate sections and separate modals - meaning, if it's a Supervision + Courts agency, they should see two separate sections on the Agency Settings page (one for Supervision Agency Definition and another for Courts Agency Definition). Sorry about the horrible confusion here - 100% my bad - I don't know why I combined them as one in my mind when writing that note. Does this clarification make sense?
Ah, very good question! For these, you can use the following structure:
So, we'll have to also allow the setting object to have an optional One more thing to clarify - the So it should appear for this configuration (they have two subpopulations included - Parole and Probation): And should NOT appear at all for this configuration: Let me know if all of this helps clarify or if there are other areas I can help clear up! Thank you for your patience, @nasaownsky. |
Hi @mxosman, thank you for clarification info!
That is hell of an engineering problem! I've tried to came up with the solution for this request, but after several trial and error I realized that this would be not as easy as I initially thought. The main issue is that we have this setting modal as a unified setting So then I came up with another solution: why don't we just display single modal with combined options for combined agencies like this: I tested this solution in multiple scenarios and it works just great! I tweaked it so that if it is combined agency and if the agency does not have any subpopulations included -- it will be just Anyway, please check out my solution and tell me what you think about it! Thank you! |
Oh that's interesting - I actually thought it would be much easier this way. I do see that both settings are unified under the
Ah, that was the goal of the original ticket write up - totally fine this solution if the above is not feasible - especially since this wouldn't be a common case (having both Court + Supervision sectors). I'm still looking through the code - but, noticed when I was playing with it that:
LMK if I should hold off on reviewing based on this conversation! |
You mean it shows up when the agency does not have any subpopulations included? It actually working correct, I think you just stumble upon bug with Supervision Populations setting section -- it does not updates UI correctly when switching agencies. Here, I made a loom demonstrating it. https://www.loom.com/share/4c36b54f83514162834d15519a8fa2d9?sid=5863bcba-4691-465b-875c-02b72ee0d82c
The field itself showing up for me correctly everytime... Do you mean it is not recording value to BE? That's because I wanted to choose our path forward -- with combined modal or not -- so I won't need to rewrite that functionality if we decide something else! |
> | ||
<Modal | ||
title={`${agencyTitle} Agency Definition`} | ||
description={ |
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.
Can the modal accept what's currently in the description
property as its children instead of feeding this all in the description
property?
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.
It seems like the modal can accept children
, and this used in Admin panel for agency and user provisioning modals, but for this exact purpose it lacks some styling. I think I was looking through code of all settings related components and made it with use of description
for the sake of uniformity. To sum up: I think we either refactor all settings components to use it as children
or keep it as description
.
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.
Gotcha! Thank you for clarifying - let's keep it as is!
publisher/src/components/AgencySettings/AgencySettingsDefinition.tsx
Outdated
Show resolved
Hide resolved
); | ||
}, [currentAgencySettings]); | ||
|
||
const isSettingConfigured = agencyDefinitionSetting.length > 0; |
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.
Will this still be a valid way to check this if the user checks and unchecks everything? I think there will still be fields here if the user unchecks everything.
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.
For the purpose of this component this would be enough since I just need to know if BE is returning something, and if it's not -- configure default setting object with the correct structure.
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.
Got it!
const isSettingConfigured = agencyDefinitionSetting.length > 0; | ||
|
||
useEffect(() => { | ||
setCurrentSystems([]); |
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.
Do we need to reset this every time the effect runs?
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.
Yeah, unfortunately we need, because when we select agency without applicable sectors we need to reset currentSystems
, otherwise it will have previous values in it. And I can't do it in reset effect here, because it depends on currentSystems
and it'll cause infinite loop.
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.
Got it - can we add a small comment here to clarify?
...((currentAgencySystems?.filter((system) => | ||
SupervisionSubsystems.includes(system) | ||
) as AgencySystemKeys[]) || []), |
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.
We could just have one variable that we set outside of this effect that gives us the list of subsystems and use that variable throughout.
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.
This includes supervision systems only, and we using them only in this effect to set currentSystems
, which could be combined.
publisher/src/components/AgencySettings/AgencySettingsDefinition.tsx
Outdated
Show resolved
Hide resolved
([key, obj]) => { | ||
return { | ||
key, | ||
included: defaultIncluded ?? obj.default, |
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.
Since we're getting the default settings, why are we also passing in a defaultIncluded
override param?
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.
When BE returns nothing we need to configure initial object, and since included
is not an optional field we need to pass "NO" as initial value on the line 159. Maybe initialIncluded
instead?
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.
Ohh I see - thank you for explaining! Hmm - how about unconfiguredDefault
?
setUpdatedSetting(defaultSetting); | ||
setDescriptionValue(""); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [agencyDefinitionSetting, currentSystems]); |
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.
Can you clarify the purpose of this effect? We already initialize it with defaultSetting
and update it via the component, no?
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.
This is a reset effect used for resetting setting for UI to work properly. The absence of this effect causes visual bug with incorrect working UI when switching agencies like here
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.
Thanks for clarifying. I'd add a small comment here too for clarity.
publisher/src/components/AgencySettings/AgencySettingsDefinition.tsx
Outdated
Show resolved
Hide resolved
if (sector.sector === system) { | ||
return { | ||
...sector, | ||
settings: sector.settings.map((setting) => | ||
setting.key === key | ||
? { | ||
...setting, | ||
included: boolToYesNoEnum(!checked), | ||
} | ||
: setting | ||
), | ||
}; | ||
} | ||
return sector; | ||
}); | ||
|
||
return updates; |
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.
Can we move this to a helper function just for readability that takes in the prevSettings
and spits out the update?
Ahh - interesting... weird that it's not updating when switching over. Thank you for pointing out that it's an unrelated bug. Hopefully it's not too gnarly to fix - thankfully the underlying logic is working and it's just the UI not updating. Side note: wIthin that same Supervision-only agency in your video - when I turn uncheck all of the subpopulations, it reverts to the Court Agency Definition instead of not showing that section at all.
Sorry for not being clear - yes, I meant it doesn't save the value. Gotcha - please disregard then - my apologies as I thought that part was ready! |
@mxosman I resolved visual issues and added other fixes, please check my changes and thank you for your thoughtful comments and questions! As for textbox implementation you suggested following structure:
but our setting is an object that could have multiple sectors, and above structure belongs to only one sector. So, in case of multiple sectors in setting object -- should we write textbox input to each sector or only to first one? |
Taking a look now! Thank you so much for your thoughtful responses and clarifications!
Good question! There should be an additional context box for each sector. So if it's a Supervision (w/ enabled subpopulations) agency + Courts agency - there should be multiple context text boxes - one for each sector/sub-sector. If the agency is just a Courts agency (for example), then the additional context belongs just to the courts sector. If it's a supervision agency with Parole and Probation, then two additional context boxes - one for Parole and another for Probation. Oh, and one quick thing - can we update the placeholder for these context boxes and replace "breakdown" with "agency"? So it reads: If the listed categories do not adequately describe your agency, please describe additional data elements included in your agency’s definition. Current placeholder for reference: |
I really appreciate you working through the complexity here - I know these new requests have been super challenging. Just know that all your efforts, creativity and patience are deeply appreciated. 🙏 |
removeEditMode(); | ||
}; | ||
|
||
const handleCheckboxChange = ( |
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.
Can you take another look at this? I'm unable to select anything in the checkboxes.
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.
It looks like it's just the supervision agency options that are affected.
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.
Fixed that!
@@ -72,6 +72,10 @@ export const AgencySettingsSupervisions: React.FC<{ | |||
userStore.isAgencyAdmin(agencyId) || | |||
userStore.isJusticeCountsAdmin(agencyId); | |||
|
|||
useEffect(() => { | |||
setSupervisionSystemsToSave(currentAgencySystems); | |||
}, [currentAgencySystems]); |
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.
Great call on this!
@mxosman Thank you for thoughtful comments and observations! This one is really tricky, but I think we are close to an end. I fixed major issue with selection that you pointed out and also added textbox functionality. Please, check my changes and let me know what you think about them. Thank you so much! |
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.
Ah, this looks and feels great! Thank you for all of your work on this, @nasaownsky! This was all tricky indeed - hopefully we'll get a break soon from all the trickiness in these requests. Left a few tiny nits and question about what ended up fixing the checkbox issue - but otherwise looks great and is ready to move on to staging - the end for this is here! Thanks again!
@@ -444,6 +444,13 @@ export const SupervisionSystemRow = styled(AgencySettingsInfoRow)<{ | |||
border: none; | |||
`; | |||
|
|||
// Agency Defifnition |
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.
tiniest nit: typo in Definition
@@ -215,6 +220,28 @@ const AgencySettingsDefinition: React.FC<{ | |||
}); | |||
}; | |||
|
|||
const handleDescriptionChange = (system: AgencySystemKeys, value: string) => { | |||
setUpdatedSetting((prevSettings) => { | |||
return prevSettings.map((sector) => { |
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.
tiny nit: setting
instead of sector
for the mapped param.
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.
Oh, this actually was resolved in this commit
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.
Ah, sorry - I was looking at the wrong commit! Thank you so much!
|
||
const initialSetting = [ | ||
...agencyDefinitionSetting, | ||
...getDefaultSetting(unconfiguredSystems, IncludesExcludesEnum.NO), |
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.
Was this what ended up fixing the checkbox issue (using the unconfiguredSystems
here)?
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.
Yeah, the problem was that once systems were written to BE, there was no way for unconfigured (or unwritten) systems to get into initialSetting
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.
Gotcha! Great catch and sleuthing!
Yay! Thank you so much for all your help on this @mxosman! |
Description of the change
Added new agency definition section for court and supervision sectors
Type of change
Related issues
closes #1540
Checklists
Development
This box MUST be checked by the submitter prior to merging:
These boxes should be checked by the submitter prior to merging:
Code review
These boxes should be checked by reviewers prior to merging: