Parse user entry of dates on the front end #2327
Labels
ready
Ready for implementation
type: enhancement
New feature or request
work: frontend
Related to frontend code in the mathesar_ui directory
Milestone
Context
In the following places, we accept user-entry of date/datetime/time values:
Current behavior
In all the above contexts, the front end attempts to parse the user input into a structured value. If it succeeds, it sends an ISO-formatted string for that value. If it fails, it sends the raw user input. Sending the raw user input allows us to handle special values like "today" and "now" that postgres is able to understand. We don't want to parse those values into dates on the front end because we want to allow the user to set filter conditions that will change based on the current date (e.g. setting the default value for a date column to "today").
This behavior is problematic because it produces this bug described in InvalidDatetimeFormat error when attempting to filter on a partially-entered date #1890.
Desired behavior
The front end maintains a list of reserved "special" date values, so far only
today
,now
,yesterday
. If the user input matches a special value, then the front end sends that special value. Otherwise...The front end attempts to parse the user input into a structured value. If it succeeds, it sends an ISO-formatted string for that value. If it fails, then it displays a client-side error, allowing the user to fix the problem before submitting any API requests.
Additional considerations
1/1/2020
) the Postgres parsing succeeds but our current parsing logic on the front end does not. When implementing this ticket, we'll need to improve the parsing logic on the front end to handle more cases like this and avoid UX regressions.Previous discussion
The text was updated successfully, but these errors were encountered: