diff options
-rw-r--r-- | apps/files_sharing/src/components/SharingEntryLink.vue | 16 | ||||
-rw-r--r-- | apps/files_sharing/src/mixins/SharesMixin.js | 16 | ||||
-rw-r--r-- | apps/files_sharing/src/views/SharingDetailsTab.vue | 7 |
3 files changed, 19 insertions, 20 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index 28c72bfc98a..3b75028c083 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -86,7 +86,7 @@ :checked.sync="defaultExpirationDateEnabled" :disabled="pendingEnforcedExpirationDate || saving" class="share-link-expiration-date-checkbox" - @change="onDefaultExpirationDateEnabledChange"> + @change="onExpirationDateToggleChange"> {{ config.isDefaultExpireDateEnforced ? t('files_sharing', 'Enable link expiration (enforced)') : t('files_sharing', 'Enable link expiration') }} </NcActionCheckbox> @@ -101,7 +101,7 @@ type="date" :min="dateTomorrow" :max="maxExpirationDateEnforced" - @input="onExpirationChange /* let's not submit when picked, the user might want to still edit or copy the password */"> + @change="expirationDateChanged($event)"> <template #icon> <IconCalendarBlank :size="20" /> </template> @@ -597,6 +597,9 @@ export default { }, mounted() { this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date + if (this.share && this.isNewShare) { + this.share.expireDate = this.defaultExpirationDateEnabled ? this.formatDateToString(this.config.defaultExpirationDate) : '' + } }, methods: { @@ -715,7 +718,7 @@ export default { path, shareType: ShareType.Link, password: share.password, - expireDate: share.expireDate, + expireDate: share.expireDate ?? '', attributes: JSON.stringify(this.fileInfo.shareAttributes), // we do not allow setting the publicUpload // before the share creation. @@ -871,9 +874,14 @@ export default { this.onPasswordSubmit() this.onNoteSubmit() }, - onDefaultExpirationDateEnabledChange(enabled) { + onExpirationDateToggleChange(enabled) { this.share.expireDate = enabled ? this.formatDateToString(this.config.defaultExpirationDate) : '' }, + expirationDateChanged(event) { + const date = event.target.value + this.onExpirationChange(date) + this.defaultExpirationDateEnabled = !!date + }, /** * Cancel the share creation diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index fdd8bbd72fd..c809b650fdf 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -110,6 +110,9 @@ export default { monthFormat: 'MMM', } }, + isNewShare() { + return !this.share.id + }, isFolder() { return this.fileInfo.type === 'dir' }, @@ -210,17 +213,8 @@ export default { * @param {Date} date */ onExpirationChange(date) { - this.share.expireDate = this.formatDateToString(new Date(date)) - }, - - /** - * Uncheck expire date - * We need this method because @update:checked - * is ran simultaneously as @uncheck, so - * so we cannot ensure data is up-to-date - */ - onExpirationDisable() { - this.share.expireDate = '' + const formattedDate = date ? this.formatDateToString(new Date(date)) : '' + this.share.expireDate = formattedDate }, /** diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index f50a533eeeb..404a8fe25e9 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -115,8 +115,8 @@ :helper-text="t('files_sharing', 'Set the public share link token to something easy to remember or generate a new token. It is not recommended to use a guessable token for shares which contain sensitive information.')" show-trailing-button :trailing-button-label="loadingToken ? t('files_sharing', 'Generating…') : t('files_sharing', 'Generate new token')" - @trailing-button-click="generateNewToken" - :value.sync="share.token"> + :value.sync="share.token" + @trailing-button-click="generateNewToken"> <template #trailing-button-icon> <NcLoadingIcon v-if="loadingToken" /> <Refresh v-else :size="20" /> @@ -556,9 +556,6 @@ export default { isGroupShare() { return this.share.type === ShareType.Group }, - isNewShare() { - return !this.share.id - }, allowsFileDrop() { if (this.isFolder && this.config.isPublicUploadEnabled) { if (this.share.type === ShareType.Link || this.share.type === ShareType.Email) { |