aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorGary Kim <gary@garykim.dev>2020-05-01 17:06:24 +0800
committerGary Kim <gary@garykim.dev>2020-05-02 18:58:41 +0800
commit8dd23f98542417829162f829c0ed63f11e1d8e3e (patch)
tree7832f2b1dd52f91661a5ef4f6329945cc0009cb9 /apps/files_sharing/src
parente77e0b0e2f034633307fcc054d582c0567090776 (diff)
downloadnextcloud-server-8dd23f98542417829162f829c0ed63f11e1d8e3e.tar.gz
nextcloud-server-8dd23f98542417829162f829c0ed63f11e1d8e3e.zip
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>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/components/SharingEntry.vue3
-rw-r--r--apps/files_sharing/src/components/SharingEntryLink.vue6
-rw-r--r--apps/files_sharing/src/mixins/SharesMixin.js11
3 files changed, 14 insertions, 6 deletions
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue
index e3f7497181f..288236abad7 100644
--- a/apps/files_sharing/src/components/SharingEntry.vue
+++ b/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>
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue
index f8b8137cd29..e1722420a49 100644
--- a/apps/files_sharing/src/components/SharingEntryLink.vue
+++ b/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>
diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js
index 8806209954a..e19af48bc7e 100644
--- a/apps/files_sharing/src/mixins/SharesMixin.js
+++ b/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'))
+ },
},
}