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

Programmatically disable cells. #37

Open
ultimaustin opened this issue Nov 10, 2020 · 5 comments
Open

Programmatically disable cells. #37

ultimaustin opened this issue Nov 10, 2020 · 5 comments

Comments

@ultimaustin
Copy link

As discussed in this thread: #23

Please can I request an enhancement to prevent the user from selecting certain cells. For any given day I know which cells are available to book and which have already been booked. I therefore need to be able to prevent the user from selecting the slots which have already been chosen by someone else.

The cells which has a "disabled" state should be styled differently to make it clear that they are not selectable and obviously would not respond to click events.

@MaxKicw
Copy link

MaxKicw commented Nov 13, 2020

Hey guys @bibekg @ultimaustin,

I needed this feature as well. Now, I build it myself and it is working fine! In my version, you are able the assign a blocked prop to the ScheduleSelector Element, and those Cells will be filtered from the selectionDraft. The blocked dates are represented in red and don't have any Event-Listeners assigned to them. If they are included in a date range they will also be filtered from the selectionDraft!

I'm not sure how I can contribute to this project and send my implemented feature to you guys. This is my first time adding a feature to an npm package that's not my own.

Would appreciate it, if you guys could check it out and maybe implement it into the package. Would be so cool. So what do in need to do for you to check it out? Branch it?

Thank you for this Scheduler, it works really well and the programming is mint 🍃

Bildschirmfoto 2020-11-13 um 11 25 46

@bibekg
Copy link
Owner

bibekg commented Nov 14, 2020

That's wonderful @MaxKicw - thanks for implementing it and for the kind words! I think you can fork the repo, then create a pull request with your proposed changes (see this guide). I'd be more than happy to give it a review!

@bibekg
Copy link
Owner

bibekg commented Nov 21, 2020

Started implementing this feature in #38 but I have a question for you @ultimaustin -- what method of specifying dates to block would be better?

Option 1

An array of Date objects -- this requires that the date objects match exactly the dates of the cells (via a comparison of .toISOString()). This also means you need to be wary of what value you're using for hourlyChunks to ensure that all the cells you want to block in a time window are being blocked.

<ScheduleSelector
  // ...
  blockedTimes={[
    new Date('2020-11-22T20:00:00.000Z'), 
    new Date('2020-11-22T21:00:00.000Z'), 
    new Date('2020-11-22T22:00:00.000Z'), 
    new Date('2020-11-22T23:00:00.000Z'), 
    new Date('2020-11-22T24:00:00.000Z')
  ]}
/>

or

Option 2

An array of date ranges (start and end Dates, inclusive of the start, exclusive of the end) -- this lets you specify a large amount of cells to block with a short syntax but will be a bit more verbose if you just want to specify a single time cell here and there.

<ScheduleSelector
  // ...
  blockedTimeRanges={[
    { from: new Date('2020-11-22T20:00:00.000Z'), to: new Date('2020-11-22T24:00:00.000Z') },
  ]}
/>

@BelvedereHenrique
Copy link

Hey guys,

I'm really needing this feature, any update on this?

@Haidar-arainx
Copy link

can we make it readonly

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

5 participants