-
Notifications
You must be signed in to change notification settings - Fork 3
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: add support for multi calendar dates #385
Conversation
🚀 Deployed on https://pr-385--dhis2-data-entry.netlify.app |
025fd7f
to
2033e7d
Compare
e069847
to
e966d20
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.
Looking good! 😎. Some things I noticed below:
Persistence
I am seeing that the date does not persist consistently to the backend (see gif). I assume there's some kind of race condition between the input.onChange completing and the handleBlur being called.
I think it would be better if we just posted to the backend (and updated the input value) on the CalendarInput's onDateSelect. We have the update onBlur in the general input cells because we want to be sure that people's changes are final before we commit them, but I think we can judge that the changes are "final" once a date is selected here (this by the way, is consistent with the boolean-radio component). Doing to update onDateSelect should simplify this as we can just pass the date value to both the mutation and the input's onChange method.
Focus
The CalendarInput component has its own onFocus
definition (https://github.com/dhis2/ui/blob/master/components/calendar/src/calendar-input/calendar-input.js#L65-L67)m so the one you're passing here isn't having an effect. As a result, the cell does not come into focus and hence you cannot get the details for this cell / the styling for active cell is not applied.
You could put the focus logic on a parent div here to solve this issue (see also the boolean-radio component for an idea).
data: { | ||
settings: { keyUiLocale }, | ||
}, | ||
} = useUserInfo() |
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 feel like it might be good to have some protection against the situation where things like this are undefined (e.g. `const {data: userInfo} = useUserInfo(); const keyUiLocale = userInfo?.settings?.keyUiLocale), but this seems to be consistent with how we've done it elsewhere in the app, so I guess we're generally choosing to trust that the backend will reply consistently.
|
||
afterEach(jest.clearAllMocks) | ||
|
||
it('renders date input component', async () => { |
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 with the test 🎉
It might be nice to have a test that checks that mutation (mocked) fires with correct date value when you select date / clear date. That might be a bit tricky to implement, but I guess that would also help with some of the logic for testing the other calendars. Could be good to add a separate ticket for adding tests if you think it's too much for the first implementation.
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.
Added a few test cases that show the mutate function being called with the correct date value on dateSelect and an empty string on clear. Doing this for gregorian, nepali and ethiopian calendars
- use UI library's CalendarInput component for date type form inputs - specify calendar type from system settings - add tests
e966d20
to
a9a65e9
Compare
bc1ae7f
to
a028f75
Compare
a028f75
to
5a4a7fc
Compare
5a4a7fc
to
ad759a3
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.
Nice! Looks great 🤩
Will also be good to update again when the improvements are made on the CalendarInput component so that we don't get the [object Object]
if a user types something in the field. But I think it makes sense to merge this PR now and then just update the ui dependency later.
Awesome! Thanks for the review.
I will work on this once the editable calendar input PR is merged. |
🎉 This PR is included in version 100.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes DHIS2-17446
Description:
Tasks
Screenshot