From 79b28eb851ce3a83e124505269838d732005f722 Mon Sep 17 00:00:00 2001 From: Miles Pool Date: Mon, 17 Aug 2020 23:10:10 +0100 Subject: [PATCH] Add strict month and year selection limits. --- README.md | 4 +++ src/App.vue | 18 ++++++---- .../_subs/CustomButton/index.vue | 12 +++++-- .../DatePicker/_subs/YearMonthSelector.vue | 35 +++++++++++++++++++ .../_subs/DatePicker/index.vue | 9 ++++- .../_subs/PickersContainer/index.vue | 1 + src/VueCtkDateTimePicker/index.vue | 9 ++++- 7 files changed, 77 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bc6e2926..fffd4853 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,9 @@ The default value for this object is: ```js { + date: { + strictDateLimits: false; + }, time: { nearestIfDisabled: true; } @@ -243,6 +246,7 @@ To override those values, pass a new object with the values you want to override | Behaviour | Description | Type | Default | | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------- | +| date.strictDateLimits | When `true`, selection of months and years will be disabled outside of any supplied limits (`min-date` – `max-date`). Set to `false`, all months and years will be selectable, even if all days are out of range. | Boolean | false | | time.nearestIfDisabled | If `true`, it will select the nearest available hour in the timepicker, if the current selected hour is disabled. Per example, if the hour is 12 but all the hours have been disabled until 14, then the 14 will be selected by default. Set `false` to disable this behaviour; the current hour will remain selected even if it has been disabled. The user cannot re-select it. | Boolean | true | # Events API diff --git a/src/App.vue b/src/App.vue index 35b0a6da..13b0d034 100644 --- a/src/App.vue +++ b/src/App.vue @@ -221,6 +221,11 @@ :disabled-weekly="demo.options.disabledWeekly" :right="demo.options.right" :no-clear-button="demo.options.noClearButton" + :behaviour="{ + date: { + strictDateLimits: demo.options.strictDateLimits + } + }" > @@ -44,6 +46,7 @@