Skip to content

Conversation

@kyzrfranz
Copy link

@kyzrfranz kyzrfranz commented Dec 16, 2016

Hey Ben, stumbled across this fr and thought what the hell - any remarks, would be happy to help some more?

#124

_withinValidRange: function(date) {
if (this._isValidDate(date)) {
return (!this.minDate || date >= this.minDate) && (!this.maxDate || date <= this.maxDate);
return (!this.minDate || date >= this.minDate) && (!this.maxDate || date <= this.maxDate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove double space

},
/**
*Array of selectable dates
* (whitelist)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add Format must be String YYYY-MM-DD here as well as on invalidDates so it's documented for people using this element stand-alone.

return false;
},

_confirmsToWhiteAndBlacklist: function(date){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Collapse these 3 into:

/**
 * Ensures that our date is valid and passes both white and black list checks.
 * @protected
 *
 * @param {Date} date
 * @return {Boolean}
 */
_checkWhiteBlackLists: function(date) {
  return this._isValidDate(date) &&
    (this.validDates || []).indexOf(this.dateFormat(date,'YYYY-MM-DD')) < 0 &&
    (this.invalidDates || []).indexOf(this.dateFormat(date,'YYYY-MM-DD')) < 0;
}

So we aren't biting the cost of always checking both lists, and checking for a valid date 3 times when we don't have to.

@admwx7
Copy link
Collaborator

admwx7 commented Sep 18, 2017

BTW, this doesn't actually address #124 since this is adding white/black list support, #124 is actually a request to be able to select a range of dates (start through end) in a single date-picker so we'll need another PR in order to resolve the issue completely, thanks for the PR though!

@admwx7
Copy link
Collaborator

admwx7 commented Sep 18, 2017

Fixes #113

@kyzrfranz
Copy link
Author

You're completely right, will change tonight.
Thanks for the remarks.

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.

3 participants