You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iD Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd #280
When I try to edit a feature in iD, a feature with a start_date and/or end_date which are just years, the Start Date and End Date boxes do not get filled in. Instead, I see console messages such as The specified value "1861" does not conform to the required format, "yyyy-MM-dd".
What should be happening?
The Start Date and End Date boxes should be filled in so the dates could be edited. But, how to accept only a year into a yyyy-MM-dd box?
Repro Steps Please provide detailed instructions to reproduce the behavior:
Go to Edit
Open your debugger
Select / find / click on any feature which has only a partial date
See that the Start Date and End Date are not filled in
See that there is a console message about the year not being a properly-formatted ISO date
By contrast:
Click a feature which has full ISO dates
See that the Start Date and End Date are filled in
See that there are no console messages complaining about the date format
The block of buildings to the west all/mostly have full dates, and fill in properly.
The Yasler Residence in the middle, has a full End Date and no Start Date. The End Date fills in properly, while the Start Date is left blank which does not result in an error message.
When a feature is being loaded for editing, perhaps the start_date and end_date could be altered if they are partial?
The values could be padded out with -01-01 for the Start Date and -12-31 for the End Date.
Problem: This essentially means altering data when one hits Save. The given date was "1961" and we alter it to "1961-01-01" on save. One could view this as "fixing" the dates so the UI works, or one could view it as "falsifying" the dates since the month & day are filled in by the computer without real research or approval.
For editing view, vector data and attributes come from the OSM API, not vector tiles. Perhaps this API could be configured to use pad_date() for these two fields?
Same problem as client-side, though: This essentially means altering data. If "1861" is sent out as "1861-01-01" then that's what would go into the editor and be saved back.
Given that, it still may be a lighter solution if it's the case that tag attributes can be redefined easily, and to include SQL functions.
changed the title [-]Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd[/-][+]iD Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd[/+]on Aug 25, 2021
One thing I always liked about “fixing” those dates server-side and only in vtiles, is that in my opinion saying something started in “1623" is not necessarily wrong, it’s just at a one year resolution. As it happens, the timeslider can operate only on complete dates, so we need to pad those out to work in the vector tiles, but in many other cases, a single-year resolution might be just fine. And someday we have to circle back to and deal with things like gothic cathedrals, which took decades to build so in those cases an accurate start date might be even more complex and less precise than a single year, much less a full date. Even if we have to ultimately make assumptions and convert those into YYYY-MM-DD on the backend to work in timeslider, I think the less we modify user-entered data the better.
In that case, I think what we'd want to do here is relax the validation rules in iD and allow both YYYY and YYYY-MM entries as valid.
relax the validation rules in iD and allow both YYYY and YYYY-MM entries as valid
They're input type="date" fields, which do not allow for that. Instead, we would need to change them to plain text fields then write some custom validation mechanism to ensure that the text string is date-like...
Got it. Well, given that #15 is going to come up eventually, and has been intermittently brought up by users as important, it seems like only a matter of time (hah!) before we have to drop an ISO format date input and come up with something more appropriate to the huge variations in time scales and precision in the OHM world.
Seems like we'd want to take an approach where we match inputs against an array of patterns, to which we can add future acceptable variants as we expand the formats we can accept and convert for timeslider compatibility. For now, that would be just three variants (I think): YYYY, YYYY-MM, and YYYY-MM-DD
Does this have any implications for the date filtering in iD? I forgot how those comparisons are working and we we're approximating the decimal date for that filtering similar to what we are doing for the vector tiles
Note that the final save doesn't fully complete since I'm just running ID locally outside of the OHM website structure, but if I do attempt to save immediately after the first point I made, with a failing date, I get an alaert box as intended.
validation is done on each input field as it is changed (that is, loses focus after having its value changed, or hitting enter after having its value changed)
on no-match, an alert is shown, the field is blanked, and the field is focused
This is working for me as expected. I get an alert, then the End Date box is cleared and focused.
Tested in Mac Chrome, Mac Firefox, Mac Safari.
Can I get additional details and walkthrough? Maybe there is something in the sequence of clicks that I hadn't anticipated, or perhaps it's something browser-specific?
I've re-tested in both, but am still seeing it work as expected.
Can you make it happen again in Firefox?
If so, when you leave the End Date field in your test (the blur event on the input, is also the change handler and validation trigger), what did you do that caused you to leave the End Date box? Tabbing to a new field, or clicking a new field? Pressing enter in the field? Clicking some button, or another feature on the map?
Update per chat:
Firefox only, not Chrome nor Safari
Firefox for Mac version 91.0.4
my own testing was on 91.0.2 though FF just updated to 92.0
But still cannot replicate... Maybe something installation specific e.g. a plugin or "stop alerts on this site" behavior that is suppressing alert popups?
Update re alert blocking ("Don't allow localhost to prompt you again") - Disabling alerts simply causes alert() to be noop, doesn't interrupt the rest of the validation. The text field is still emptied and focused.
Updated update We found that Dan's Firefox can do this almost at will, while mine will only do it once in a while if I keep fussing at it, changing fields repeatedly and the validation missing maybe 1 in 15 times. Our best guess is that his Firefox is faster or slower than mine (he uses it as his default, has lots of tabs at all times; I do not), so some event handlers are running differently. Bottom line, though, is if I keep fussing at it, I can get it to fail now and then... so that's a start.
After much fussing, I found that tab and shift-tab don't reliably trigger the blur & change events in Firefox. Below is an example where I tabbed out of the field, and only the four "letter" events actually came through.
Screenshot: Example of letter events but not tab-blur event
Screenshot: Another example, no shift-tab event the 5th time
Via Google I see that this is a known issue dating back some time, and reported in relation to several JavaScript libraries, though not particularly recently. Tabbing reliably triggers in Chrome, but in Firefox it sometimes simply doesn't send an event. The usual recommendation is to add keydown events to detect tab and trigger the change handler...
All righty! See current version of gin-issue280-startenddate_format branch.
adds keydown event handler, if Tab (includes shift-Tab) then triggers change event handler, even on Firefox
moved the validation code directly into change() instead of helper function
smaller diff footprint
needs to potentially reset val as a side effect if altering their data
added new feature: integer-looking strings with under 4 digits, are coerced to 4 digits e.g. "345" and "-20" will become "0345" and "-0020" and therefore valid
Activity
gregallensworth commentedon Aug 25, 2021
Option: Expanding the dates client-side
When a feature is being loaded for editing, perhaps the
start_dateandend_datecould be altered if they are partial?The values could be padded out with -01-01 for the Start Date and -12-31 for the End Date.
Problem: This essentially means altering data when one hits Save. The given date was "1961" and we alter it to "1961-01-01" on save. One could view this as "fixing" the dates so the UI works, or one could view it as "falsifying" the dates since the month & day are filled in by the computer without real research or approval.
gregallensworth commentedon Aug 25, 2021
Option: Expanding the dates server-side
There exist for PostgreSQL a date-expansion function, which will pad out "1861" to "1861-01-01" or to "1861-12-31" as needed. https://github.com/OpenHistoricalMap/DateFunctions-plpgsql#varchar-pad_datedatelikestring-varchar-startend-varchar--start
For editing view, vector data and attributes come from the OSM API, not vector tiles. Perhaps this API could be configured to use
pad_date()for these two fields?https://openhistoricalmap.org/api/0.6/map?bbox=-122.3382568359375,47.59875528481799,-122.332763671875,47.60245929546311
Same problem as client-side, though: This essentially means altering data. If "1861" is sent out as "1861-01-01" then that's what would go into the editor and be saved back.
Given that, it still may be a lighter solution if it's the case that tag attributes can be redefined easily, and to include SQL functions.
jeffreyameyer commentedon Aug 25, 2021
This is on ID, right?
I have no real issue with padding out the MM-DD on non-specified dates, as long as we add something like:
fixme=start_date, end_date
or even
fixme.start_date = yes
fixme.end_date = yes
or start_date = machine padded
etc.
Just some trail of the machine default, so we can find it later.
i.e. altering is fine, as long as we make note of it.
Make sense?
Good catch, too... this has always bothered me...
[-]Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd[/-][+]iD Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd[/+]danrademacher commentedon Aug 25, 2021
One thing I always liked about “fixing” those dates server-side and only in vtiles, is that in my opinion saying something started in “1623" is not necessarily wrong, it’s just at a one year resolution. As it happens, the timeslider can operate only on complete dates, so we need to pad those out to work in the vector tiles, but in many other cases, a single-year resolution might be just fine. And someday we have to circle back to and deal with things like gothic cathedrals, which took decades to build so in those cases an accurate start date might be even more complex and less precise than a single year, much less a full date. Even if we have to ultimately make assumptions and convert those into
YYYY-MM-DDon the backend to work in timeslider, I think the less we modify user-entered data the better.In that case, I think what we'd want to do here is relax the validation rules in iD and allow both
YYYYandYYYY-MMentries as valid.gregallensworth commentedon Aug 25, 2021
Replying to #280 (comment)
They're
input type="date"fields, which do not allow for that. Instead, we would need to change them to plain text fields then write some custom validation mechanism to ensure that the text string is date-like...danrademacher commentedon Aug 25, 2021
Got it. Well, given that #15 is going to come up eventually, and has been intermittently brought up by users as important, it seems like only a matter of time (hah!) before we have to drop an ISO format date input and come up with something more appropriate to the huge variations in time scales and precision in the OHM world.
Seems like we'd want to take an approach where we match inputs against an array of patterns, to which we can add future acceptable variants as we expand the formats we can accept and convert for timeslider compatibility. For now, that would be just three variants (I think):
YYYY,YYYY-MM, andYYYY-MM-DDgregallensworth commentedon Aug 25, 2021
Okay, so change to text inputs and add custom validation code.
change
start_dateandend_dateinputs to text fieldsadd a custom validation to enforce one of those three patterns
danrademacher commentedon Aug 25, 2021
Does this have any implications for the date filtering in iD? I forgot how those comparisons are working and we we're approximating the
decimal datefor that filtering similar to what we are doing for the vector tilesOpenHistoricalMap/issues#280 Save button validation, start and end dates
OpenHistoricalMap/issues#280 Save button validation, start and end dates
1 remaining item
danrademacher commentedon Sep 1, 2021
Here's a screencast of that flow:
https://recordit.co/gafDosl5ze
Note that the final save doesn't fully complete since I'm just running ID locally outside of the OHM website structure, but if I do attempt to save immediately after the first point I made, with a failing date, I get an alaert box as intended.
OpenHistoricalMap/issues#280 start_date end_date validation on input
gregallensworth commentedon Sep 3, 2021
A new approach:
See branch
gin-issue280-startenddate_formatand PR https://github.com/OpenHistoricalMap/iD/pull/81/filesdanrademacher commentedon Sep 8, 2021
Hmm, this is now working as expected for me on start_date:

But not on end_date:

I looked a bit at the code and markup to see why that might be, but I can't tell. Maybe the select pattern on the end_date is somehow different?
gregallensworth commentedon Sep 8, 2021
Replying to #280 (comment)
This is working for me as expected. I get an alert, then the End Date box is cleared and focused.
Tested in Mac Chrome, Mac Firefox, Mac Safari.
Can I get additional details and walkthrough? Maybe there is something in the sequence of clicks that I hadn't anticipated, or perhaps it's something browser-specific?
danrademacher commentedon Sep 8, 2021
aha, it is working for me as expected in Chrome. I was testing previous in Firefox
gregallensworth commentedon Sep 8, 2021
gregallensworth commentedon Sep 8, 2021
I've re-tested in both, but am still seeing it work as expected.
Can you make it happen again in Firefox?
If so, when you leave the End Date field in your test (the
blurevent on the input, is also thechangehandler and validation trigger), what did you do that caused you to leave the End Date box? Tabbing to a new field, or clicking a new field? Pressing enter in the field? Clicking some button, or another feature on the map?Update per chat:
But still cannot replicate... Maybe something installation specific e.g. a plugin or "stop alerts on this site" behavior that is suppressing alert popups?
Update re alert blocking ("Don't allow localhost to prompt you again") - Disabling alerts simply causes
alert()to be noop, doesn't interrupt the rest of the validation. The text field is still emptied and focused.Updated update We found that Dan's Firefox can do this almost at will, while mine will only do it once in a while if I keep fussing at it, changing fields repeatedly and the validation missing maybe 1 in 15 times. Our best guess is that his Firefox is faster or slower than mine (he uses it as his default, has lots of tabs at all times; I do not), so some event handlers are running differently. Bottom line, though, is if I keep fussing at it, I can get it to fail now and then... so that's a start.
gregallensworth commentedon Sep 9, 2021
After much fussing, I found that tab and shift-tab don't reliably trigger the blur & change events in Firefox. Below is an example where I tabbed out of the field, and only the four "letter" events actually came through.
Screenshot: Example of letter events but not tab-blur event
Screenshot: Another example, no shift-tab event the 5th time
Via Google I see that this is a known issue dating back some time, and reported in relation to several JavaScript libraries, though not particularly recently. Tabbing reliably triggers in Chrome, but in Firefox it sometimes simply doesn't send an event. The usual recommendation is to add keydown events to detect tab and trigger the change handler...
OpenHistoricalMap/issues#280 Start End Date, event and validity rewor…
OpenHistoricalMap/issues#280 Start End Date, event and validity rewor…
gregallensworth commentedon Sep 9, 2021
All righty! See current version of gin-issue280-startenddate_format branch.
keydownevent handler, if Tab (includes shift-Tab) then triggers change event handler, even on Firefoxchange()instead of helper functionvalas a side effect if altering their datadanrademacher commentedon Sep 21, 2021
This was fixed and deployed last week