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

Availability for the date range picker #891

Merged
merged 2 commits into from
Aug 9, 2018
Merged

Conversation

lyyder
Copy link
Contributor

@lyyder lyyder commented Aug 8, 2018

Overview

Adds support for availability to FieldDateRangeInput. It is used by passing a timeSlots prop that contains available dates.

Features

Nightly booking

When using nightly booking, the end date can be selected between the start date and the following booked date, including the booked date.

nightly

Daily booking

When using daily booking, the end date can be selected between the start date and the following booked date, excluding the booked date.

daily

Selecting end date first

When selecting end date first, the possible start dates are limited by the previous booked date from the end date.

endfirst

Updating start date

After both dates are selected, updating the start date to a date before a booked date that is between the new and old start dates, the end date is cleared.

updatestart

@lyyder lyyder force-pushed the date-range-input-availability branch 2 times, most recently from 19addae to d613621 Compare August 8, 2018 13:17
@lyyder lyyder force-pushed the date-range-input-availability branch from d613621 to 1263340 Compare August 8, 2018 13:24
@lyyder
Copy link
Contributor Author

lyyder commented Aug 8, 2018

A changelog entry is coming in a PR that uses this feature in the template.


const lastBlockedBetweenExclusive = (timeSlots, startDate, endDate) => {
if (startDate.isSame(endDate, 'date')) {
return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to null

const firstBlockedBetween = (timeSlots, startDate, endDate) => {
const firstDate = moment(startDate).add(1, 'days');
if (firstDate.isSame(endDate, 'date')) {
return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to null

const lastBlockedBetween = (timeSlots, startDate, endDate) => {
const previousDate = moment(endDate).subtract(1, 'days');
if (previousDate.isSame(startDate, 'date')) {
return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to null

Copy link
Contributor

@Gnito Gnito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change undefined returns to nulls

@lyyder lyyder merged commit b9b2b6c into master Aug 9, 2018
@lyyder lyyder deleted the date-range-input-availability branch August 24, 2018 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants