-
Notifications
You must be signed in to change notification settings - Fork 3
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(datepicker): step 3, excluding dates #219
Conversation
@@ -23,10 +23,17 @@ class OdsDatepickerController { | |||
if (newValue === undefined || newValue === null || isNaN(newValue.getTime())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add also || !this.validateValue(newValue)
condition and remove the last else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a function for add context like isValidValue
|
||
private validateValue(value?: Date) { | ||
if (value) { | ||
if (!this.component.maxDate || this.getMidnightDate(value).getTime() <= this.getMidnightDate(this.component.maxDate).getTime() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should split your validation and avoid calling the same function (getMidnightDate
) so many times, more like
if (!value) {
return false;
}
const midnightDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))
if (this.component.maxDate) {
return <test max date>
}
if (this.component.minDate) {
return <test max date>
}
...
packages/components/datepicker/src/components/osds-datepicker/core/controller.ts
Outdated
Show resolved
Hide resolved
packages/components/datepicker/src/components/osds-datepicker/core/controller.ts
Outdated
Show resolved
Hide resolved
@@ -23,10 +23,17 @@ class OdsDatepickerController { | |||
if (newValue === undefined || newValue === null || isNaN(newValue.getTime())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a function for add context like isValidValue
defaultValue: null, | ||
options: [null, new Date('1999-11-02'), new Date('2024-11-02')], | ||
}, | ||
minDate: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/components/datepicker/src/components/osds-datepicker/osds-datepicker.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* feat(datepicker): step 3, excluding dates * feat(datepicker): step 3, excluding dates
* feat(datepicker): step 3, excluding dates * feat(datepicker): step 3, excluding dates
Adding options to disable specific dates of the Datepicker.
New enum:
ODS_DATEPICKER_DAY
: monday = 1, saturday = 6, etc.New attributes: