Skip to content
Snippets Groups Projects
Unverified Commit 8dd23f98 authored by Gary Kim's avatar Gary Kim
Browse files

Fix expiry datepicker allowing all dates


vue2-datepicker expects a `disabled-date` function
rather than `not-before` and `not-after` dates.

This commit updates it so that we now provide
vue2-datepicker with a `disabled-date` function.

Signed-off-by: default avatarGary Kim <gary@garykim.dev>
parent e77e0b0e
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -95,8 +95,7 @@ ...@@ -95,8 +95,7 @@
value-type="format" value-type="format"
icon="icon-calendar-dark" icon="icon-calendar-dark"
type="date" type="date"
:not-before="dateTomorrow" :disabled-date="disabledDate"
:not-after="dateMaxEnforced"
@update:value="onExpirationChange"> @update:value="onExpirationChange">
{{ t('files_sharing', 'Enter a date') }} {{ t('files_sharing', 'Enter a date') }}
</ActionInput> </ActionInput>
......
...@@ -105,8 +105,7 @@ ...@@ -105,8 +105,7 @@
icon="" icon=""
type="date" type="date"
value-type="format" value-type="format"
:not-before="dateTomorrow" :disabled-date="disabledDate">
:not-after="dateMaxEnforced">
<!-- let's not submit when picked, the user <!-- let's not submit when picked, the user
might want to still edit or copy the password --> might want to still edit or copy the password -->
{{ t('files_sharing', 'Enter a date') }} {{ t('files_sharing', 'Enter a date') }}
...@@ -231,8 +230,7 @@ ...@@ -231,8 +230,7 @@
value-type="format" value-type="format"
icon="icon-calendar-dark" icon="icon-calendar-dark"
type="date" type="date"
:not-before="dateTomorrow" :disabled-date="disabledDate"
:not-after="dateMaxEnforced"
@update:value="onExpirationChange"> @update:value="onExpirationChange">
{{ t('files_sharing', 'Enter a date') }} {{ t('files_sharing', 'Enter a date') }}
</ActionInput> </ActionInput>
......
...@@ -300,5 +300,16 @@ export default { ...@@ -300,5 +300,16 @@ export default {
debounceQueueUpdate: debounce(function(property) { debounceQueueUpdate: debounce(function(property) {
this.queueUpdate(property) this.queueUpdate(property)
}, 500), }, 500),
/**
* Returns which dates are disabled for the datepicker
* @param {Date} date date to check
* @returns {boolean}
*/
disabledDate(date) {
const dateMoment = moment(date)
return (this.dateTomorrow && dateMoment.isBefore(this.dateTomorrow, 'day'))
|| (this.dateMaxEnforced && dateMoment.isSameOrAfter(this.dateMaxEnforced, 'day'))
},
}, },
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment