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

Today default for date widget #336

Closed
jimafisk opened this issue Aug 9, 2024 · 2 comments
Closed

Today default for date widget #336

jimafisk opened this issue Aug 9, 2024 · 2 comments

Comments

@jimafisk
Copy link
Member

jimafisk commented Aug 9, 2024

In _defaults.json if you put string that matches our date patterns, the CMS will automatically give you a date widget. For example:

{
 "date": "1/1/2024"
}

However, as the months pass this day becomes quite stale and content editors have to click to bring the widget to the current day (something that is typically wanted when creating content). It would be nice if the date widget automatically picked up on a value of "today" and converted this to the current date. For example:

{
 "date": "today"
}

One challenge here is that we also try to retain the date format used in your defaults when displaying (1-1-24 would display different than 1/1/24), so we'd have to infer the format used here. We should probably extend the date field widget to allow setting this via options in _schema.json:

"date": {
  "type": "date",
  "options": [
    "Jan 1, 2024"
  ]
}

We may want to eventually add other modifiers like yesterday, + N days, - N days, etc.

@jimafisk
Copy link
Member Author

Or does it make more sense the other way around, having the defaults set the format (e.g. 1-1-24) and having schema define the adjustment (e.g. today) in options.

@jimafisk
Copy link
Member Author

This should be available in v0.6.54

You can now use the following options in your date schema:

  • today
  • today+N (where N is replaced with a real number like 1)
  • today-N (where N is replaced with a real number like 42)

An example _schema.json file might look like:

{
	"my_date": {
		"type": "date",
		"options": ["today + 3"]
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant