duetds/date-picker

provide configuration option that controls granularity of date selection

marcbertone opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
In some cases, a provider may want the end-user to select a month, rather than a specific day. For example, if a bank provides monthly statements it would be beneficial to show the end-user a selection tool that only prompts for year and month, without the unnecessary day selection.

Describe the solution you'd like
Addition of a configuration option that controls the granularity of the date-picker instance. One approach is a simple toggle to switch between "select day" and "select month" mode, with "day" selected as the default. A second would be supporting multiple levels of granularity:

  • day (default)
  • week (may not be useful, but adding for completeness sake)
  • month
  • quarter (may not be useful, but adding for completeness sake)
  • year

Describe alternatives you've considered
Using the dateAdapter it is possible to change the text display from "YYYY-MM-DD" to "YYYY-MM", but the end-user is still prompted to select a specific day when the provider only wants to receive the selected month.

Additional context
Similar functionality is available in older Bootstrap-reliant components.

With CSS and JS event handling, I can hide the day selection table on-open and retrieve the user-selected month + year values on-close. This is functional - although I have no idea if these hacks will be future proof. And the resulting UI is not ideal, as the month + year selection interface only uses a small portion of the available date picker space.
image