[PER-10643] Add edtf date and time validation#1056
Open
aasandei-vsp wants to merge 14 commits into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## PER-10642-create-edtf-date-modal-component #1056 +/- ##
==============================================================================
+ Coverage 51.62% 51.81% +0.19%
==============================================================================
Files 354 354
Lines 12055 12109 +54
Branches 2166 2175 +9
==============================================================================
+ Hits 6223 6274 +51
- Misses 5607 5608 +1
- Partials 225 227 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2a3db6f to
215f0c0
Compare
f3c2c87 to
374ded6
Compare
Contributor
Author
|
@cecilia-donnelly @slifty I have managed to rebase this one on the branch that's been checked out from too :D |
44786c5 to
6de3071
Compare
Created a new component that shows a dropdown for picking up a date in the sidebar. This uses the date and time pickers and integrates with the BE. Issue: PER-10641
The integration of the sidebar-date-picker component in the sidebar is hidden under a flag. Issue: PER-10641
In the edtf date dropdown and modal, when year, month or day have undefined digits, replace them with X values for display and leave them as empty in the inputs. PER-10641
Normalize the Intl-produced timezone name so offset-only zones display as e.g. GMT+03:00. Issue: PER-10641
- Cache displayTimeObject instead of recomputing it in a template getter. - Show a translatable generic error on save failure; log the raw error. - Remove the unused isNumeric helper. Issue: PER-10641
- Zero-pad single-digit days left ("9" -> "09") instead of X-padding,
which produced invalid days that failed to save.
- Accept a lone digit so backspace works on a padded day like "05".
- Re-sync the picker to the stored value when a save fails.
Issue: PER-10641
In the edtf date dropdown and modal, when year, month or day have undefined digits, replace them with X values for display and leave them as empty in the inputs. PER-10641
In order to be able to input an edtf date, the modal includes components that will help with qualifiers and intervals. Issue: PER-10642
Each date in an interval now has its own Approximate / Uncertain / Unknown toggles. The sidebar reads "Sometime before/after" for open intervals and "Unknown" for unknown sides. Issue: PER-10642
215f0c0 to
a71e024
Compare
6de3071 to
1c74479
Compare
Member
|
Thanks for the branch management! For others reading this (QA), this needs a feature flag to be turned on: |
cecilia-donnelly
left a comment
Member
There was a problem hiding this comment.
I love the way this is looking! The "sometime before"/"sometime after" language for an open ended range is very cool.
- I did see that if I enter February 29 in a non-leap-year, the error is "Day must be between 1 and 31" which is not exactly what we want to express there. I'm not sure what this should be, but maybe @omnignorant knows.
- If I leave both start and end dates empty and indicate that this is a range then I get "sometime before .." which isn't exactly right either
- If I have an open range (no start or end dates), then remove the "range" indicator, the new value is an empty string which gets an error from the backend. Maybe that's fine, but maybe we should instead send "Unknown"? QA/design question.
- the sidebar behaves slightly differently from the modal for invalid data. The sidebar allows you to click "save" with only a time filled (no date) while the modal blocks that path. The time-only value doesn't save, but in the sidebar the user gets a "We could not update" error in a toast instead of the nicer inline "A complete date is required when time is provided."
None of these are showstoppers, but if possible would be nice to fix!
Extract the detault qualifiers into a shared constant. Add a display update in the sidebar when the modal saves a new date. Issue: PER-10642
a71e024 to
3876198
Compare
Left-pad single-digit month and day values with zero instead of
X-padding them, since a single 1-9 digit can only be a complete value
('5' -> '05', no longer '5X'). Require a complete date whenever a time
is provided and surface a dedicated friendly error message for that
case. Add a generic getSegmentError helper that the datepicker and
timepicker inputs use to build their inline field error messages
(invalid characters and out-of-range checks, skipped while the value
is still being typed).
Issue: PER-10643
Instead of silently rejecting invalid input, the year, month and day segments now emit whatever the user typed and surface a per-field error message below the input (invalid characters, out-of-range month or day). The day is re-validated when the month changes, and picking a date from the calendar clears all errors. The error styling lives in new shared input-error-state and input-error-message mixins. Issue: PER-10643
Instead of silently rejecting invalid input, the hours, minutes and seconds segments now emit whatever the user typed and surface a per-field error message below the input. The hour is re-validated when the AM/PM/24H format changes. Issue: PER-10643
The inline-error restructure dropped role="button", tabindex, and the keydown.enter/space handlers from the calendar and clock toggle buttons, leaving them mouse-only. Restore them and add keyboard-toggle tests. Issue: PER-10643
1c74479 to
fe7dd07
Compare
3876198 to
b6b99b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Manual test cases — Date/time input inline validation
Setup: log in, upload a file, click it.
EXPECTED: sidebar with a Date section. Open the edit modal via "More options" for each test.
Invalid characters
19abin the year, thenabin the hours.Out-of-range month
13in the month input.12.Out-of-range day
2026, month04, then type31in the day input.30.Out-of-range hours (AM/PM mode)
13in the hours input.10.Out-of-range minutes
60in the minutes input.59.Out-of-range seconds
60in the seconds input.59.No error while typing a single digit
5in the month or9in the day.2026-05, not2026-5X).Day re-validated when the month changes
2026/01/31(no error), then change the month to04.2025but not in2024.Hour re-validated when the format changes
15(no error), then toggle to AM.24.Calendar selection clears errors
Time without a complete date
1985, month05, no day, and a time of 10:30 AM.1985-05-20T10:30:00.