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

feat: add new edgesOnly to return only start/end dates in selection range #275

Merged
merged 4 commits into from
Aug 2, 2024

Conversation

ghiscoding
Copy link
Contributor

@ghiscoding ghiscoding commented Jul 29, 2024

  • when using multiple-ranged, it will by default push all the range dates in the settings.selected.dates, however in some cases we are sometime only interested in the Start/End dates (first & last). For example, if we have a range of Jan 1st to Feb 28, it will push 59 days to the settings.selected.dates array, however with edgesOnly, it will only push 2 dates in the array which are equal to the Start/End dates
  • for a project like mine with a data grid, I'm only interested in the Start/End dates so that I can use it to filter my grid data by comparing dates between X start date and Y end date. So I'm really only interested in the edges (start/end) and I don't care about the dates that are in the middle, I really don't need to know what the dates are in the middle dates since the start/end is all I really need (hence why I'm adding this new feature)
  • this option can be extremely useful when the user selects a date range that spans over multiple months (6 months or 1 year range would create a very large array of selected dates, when in reality we sometime just want to know the date range start/end dates for filtering purposes or anything similar)
  • Note: I'm already using this code in production from my fork of your project, I hope to switch back to your original project as soon as all my PRs are hopefully accepted :)

Below is an example making a date range selection which starts on April 4th and ends on April 14th

image

with edgesOnly: true, it will return only 2 dates in the array, the start & ending dates. I can then call this simple line of code to retrieve start/end dates const [start, end] = self.selectedDates;

image

but without edgesOnly (false or undefined which is the default), it will return all dates in the array

image

- when using `multiple-ranged`, it will by default push **all** the range dates in the `settings.selected.dates`, however in some cases we are only interested in the start/end dates. For example, if we have a range of Jan 1st to Feb 28, it will push 59 days to `settings.selected.dates` array, however with `edgesOnly`, we'll only push the 2 dates which are equal to the start & end dates
@ghiscoding ghiscoding changed the title feat: add new edgesOnly to return only start/end dates in selection feat: add new edgesOnly to return only start/end dates in selection range Jul 30, 2024
@uvarov-frontend
Copy link
Owner

I returned the wrong indentation to get rid of the eslint error, although I agree that your indentation is correct.
Screen-Shot-2024-08-02-14-42-37

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

Successfully merging this pull request may close these issues.

2 participants