-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: [DHIS-11419] display assigned users on events in enrollment overview page #3453
Conversation
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! 👏
@@ -92,7 +92,7 @@ const valueConvertersForType = { | |||
[dataElementTypes.FILE_RESOURCE]: convertResourceForDisplay, | |||
[dataElementTypes.IMAGE]: convertResourceForDisplay, | |||
[dataElementTypes.ORGANISATION_UNIT]: (rawValue: Object) => rawValue.name, | |||
[dataElementTypes.ASSIGNEE]: (rawValue: Object) => `${rawValue.name} (${rawValue.username})`, | |||
[dataElementTypes.ASSIGNEE]: (rawValue: Object) => `${rawValue.name || rawValue.displayName} (${rawValue.username})`, |
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.
NIT: There is an edge case where displayName
is undefined. To reproduce, create a new enrollment event, you will be redirected to the enrollment overview and the undefined (undefined)
text will appear in the program stage table. You must refresh the page to see the correct value of displayName
.
This happens because only the uid
property is stored in Redux (within enrollmentDomain
) when the event is created. The solution is quite straightforward and I already needed to fix it in one of the other related tickets in the epic DHIS2-15480.
Thanks!
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 @simonadomnisoru! Implemented the fix so that it won't come up as an issue during testing. I tried undoing the change I did on this line, but that didn't work. Seems like removing rawValue.name
works, though. But it also seems like a risky thing to do. Do you think it would break something?
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.
To undo the change, you can add a converter for dataElementTypes.ASSIGNEE
inside serverToClient. Something like this should work:
[dataElementTypes.ASSIGNEE]: (serverValue: ApiAssignedUser) => ({
id: serverValue.uid,
name: serverValue.displayName,
username: serverValue.username,
firstName: serverValue.firstName,
surname: serverValue.surname,
}),
This ensures that when the assignedUser value reaches the clientToList
converter, it is in the correct format. Thanks!
🚀 Deployed on https://deploy-preview-3453--dhis2-capture.netlify.app |
@@ -8,7 +8,7 @@ const query = { | |||
id: ({ id }) => id, | |||
params: { | |||
fields: | |||
['programStages[id,repeatable,hideDueDate,programStageDataElements[displayInReports,dataElement[id,valueType,displayName,displayFormName,optionSet[options[code,name]]]'], | |||
['programStages[id,repeatable,hideDueDate,enableUserAssignment,programStageDataElements[displayInReports,dataElement[id,valueType,displayName,displayFormName,optionSet[options[code,name]]]'], |
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 you know the reason why useProgramMetadata
is retrieving data from the api instead of using the IndexedDB cache? If not, can you change it to use useIndexedDBQuery
?
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.
I'm not sure, but it could perhaps be related to translations, i.e. displayName
needs to come from the server?
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 have a ticket to fix the displayName cache problem. Great if you change this one to use useIndexedDBQuery
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.
@JoakimSM programStageDataElements
in IndexedDB doesn't contain the dataelement subvalues like valueType
and optionSet
. Do you think we can solve that with local data as well?
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.
If I understand you correctly, there is a separate store/table for data elements. Should be retrieved from there.
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.
Changed the metadata source in this case from the server to IndexedDB. The code got rather complicated the way I did it though. Got any suggestions for making it less complicated?
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.
I don't think it looks too bad. But, what is the advantage of using your custom useQueryStyleEvaluation
instead of useIndexedDBQuery
like we do in useProgramFromIndexedDB
?
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's just how the caching is done. I think useIndexedDBQuery
generally uses time to determine when to clear out a cache entry, which in this case doesn't feel very natural to me. useQueryStyleEvaluation
does the caching like useMemo
would.
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 would be beneficial to have one approach for this and currently that is useIndexedDBQuery
. If we don't like the approach there, we can look into what we don't like and change it for all queries to IndexedDB. But let's start by using useIndexedDBQuery
.
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.
Looks good @superskip! 🎉
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.
Tested successfully on 2.41,2.40.3,2.39.5,2.38.6 versions
# [100.50.0](v100.49.0...v100.50.0) (2023-12-18) ### Features * [DHIS-11419] display assigned users on events in enrollment overview page ([#3453](#3453)) ([44fb2be](44fb2be))
🎉 This PR is included in version 100.50.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Jira issue description:
The program Malaria focus registration can be used for testing.