Browse Source

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: Gary Kim <gary@garykim.dev>
pull/20762/head
Gary Kim 6 years ago
parent
commit
8dd23f9854
No known key found for this signature in database GPG Key ID: 9349B59FB54594AC
  1. 6
      apps/files_sharing/js/dist/files_sharing_tab.js
  2. 2
      apps/files_sharing/js/dist/files_sharing_tab.js.map
  3. 3
      apps/files_sharing/src/components/SharingEntry.vue
  4. 6
      apps/files_sharing/src/components/SharingEntryLink.vue
  5. 11
      apps/files_sharing/src/mixins/SharesMixin.js

6
apps/files_sharing/js/dist/files_sharing_tab.js
File diff suppressed because it is too large
View File

2
apps/files_sharing/js/dist/files_sharing_tab.js.map
File diff suppressed because it is too large
View File

3
apps/files_sharing/src/components/SharingEntry.vue

@ -95,8 +95,7 @@
value-type="format"
icon="icon-calendar-dark"
type="date"
:not-before="dateTomorrow"
:not-after="dateMaxEnforced"
:disabled-date="disabledDate"
@update:value="onExpirationChange">
{{ t('files_sharing', 'Enter a date') }}
</ActionInput>

6
apps/files_sharing/src/components/SharingEntryLink.vue

@ -105,8 +105,7 @@
icon=""
type="date"
value-type="format"
:not-before="dateTomorrow"
:not-after="dateMaxEnforced">
:disabled-date="disabledDate">
<!-- let's not submit when picked, the user
might want to still edit or copy the password -->
{{ t('files_sharing', 'Enter a date') }}
@ -231,8 +230,7 @@
value-type="format"
icon="icon-calendar-dark"
type="date"
:not-before="dateTomorrow"
:not-after="dateMaxEnforced"
:disabled-date="disabledDate"
@update:value="onExpirationChange">
{{ t('files_sharing', 'Enter a date') }}
</ActionInput>

11
apps/files_sharing/src/mixins/SharesMixin.js

@ -300,5 +300,16 @@ export default {
debounceQueueUpdate: debounce(function(property) {
this.queueUpdate(property)
}, 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'))
},
},
}
Loading…
Cancel
Save