Skip to content
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

Parse user entry of dates on the front end #2327

Open
seancolsen opened this issue Jan 20, 2023 · 1 comment
Open

Parse user entry of dates on the front end #2327

seancolsen opened this issue Jan 20, 2023 · 1 comment
Assignees
Labels
ready Ready for implementation type: enhancement New feature or request work: frontend Related to frontend code in the mathesar_ui directory
Milestone

Comments

@seancolsen
Copy link
Contributor

seancolsen commented Jan 20, 2023

Context

In the following places, we accept user-entry of date/datetime/time values:

  • Cells, when saving values
  • Filter conditions, when filtering the table page, or an exploration
  • Inputs when searching via the record selector
  • Inputs when saving a record on the Table Page
  • Inputs, when setting a default value for a column

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.

    image

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

  • I noticed that for some formats (e.g. 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

@seancolsen seancolsen added ready Ready for implementation type: enhancement New feature or request work: frontend Related to frontend code in the mathesar_ui directory restricted: maintainers Only maintainers can resolve this issue labels Jan 20, 2023
@seancolsen seancolsen added this to the Backlog milestone Jan 20, 2023
@github-actions github-actions bot added the stale label Aug 8, 2023
@rajatvijay rajatvijay removed the stale label Aug 9, 2023
@mathesar-foundation mathesar-foundation deleted a comment from github-actions bot Dec 4, 2023
@dikwickley
Copy link

@seancolsen I would like to work on this 😃

@seancolsen seancolsen removed the restricted: maintainers Only maintainers can resolve this issue label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Ready for implementation type: enhancement New feature or request work: frontend Related to frontend code in the mathesar_ui directory
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants