Skip to content

Commit

Permalink
Fix naming and documentation
Browse files Browse the repository at this point in the history
Signed-off-by: julia.kirschenheuter <julia.kirschenheuter@nextcloud.com>
  • Loading branch information
JuliaKirschenheuter committed Sep 6, 2022
1 parent 062f7f0 commit 4115f93
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
27 changes: 17 additions & 10 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<!-- expiration date -->
<NcActionCheckbox :checked.sync="hasExpirationDate"
:disabled="config.isDefaultInternalExpireDateEnforced || saving"
@uncheck="uncheckExpirationDateCheckbox">
@uncheck="uncheckExpirationDate">
{{ config.isDefaultInternalExpireDateEnforced
? t('files_sharing', 'Expiration date enforced')
: t('files_sharing', 'Set expiration date') }}
Expand All @@ -99,7 +99,7 @@
:hide-label="true"
:class="{ error: errors.expireDate}"
:disabled="saving"
:value="computeValueExpiredDate"
:value="expireDate"
type="date"
:min="dateTomorrow"
:max="dateMaxEnforced"
Expand Down Expand Up @@ -176,7 +176,7 @@ export default {
permissionsDelete: OC.PERMISSION_DELETE,
permissionsRead: OC.PERMISSION_READ,
permissionsShare: OC.PERMISSION_SHARE,
isFirstInitExpiredDate: true,
isFirstInitOfExpireDate: true,
}
},

Expand Down Expand Up @@ -431,11 +431,15 @@ export default {
return this.isFolder || allowedMimetypes.includes(this.fileInfo.mimetype)
},

computeValueExpiredDate() {
if (this.isFirstInitExpiredDate) {
/**
* Compute value for expiration input field
* @return {Date}
*/
expireDate() {
if (this.isFirstInitOfExpireDate) {
// initial value needs to be set to one day after share.expireDate because the min value of input is dateTomorrow
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.isFirstInitExpiredDate = false
this.isFirstInitOfExpireDate = false
return new Date(new Date().setDate(this.share.expireDate.getDate() + 1))
}
return this.share.expireDate
Expand Down Expand Up @@ -472,10 +476,13 @@ export default {
this.onNoteSubmit()
},

uncheckExpirationDateCheckbox() {
this.isFirstInitExpiredDate = true
return this.uncheckExpirationDateCheckbox
}
/**
* Process unchecking of checkbox for expiration date
*/
uncheckExpirationDate() {
this.isFirstInitOfExpireDate = true
return this.onExpirationDisable()
},
},
}
</script>
Expand Down
32 changes: 19 additions & 13 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,14 @@
{{ t('files_sharing', 'Expiration date (enforced)') }}
</NcActionText>
<NcActionInput v-if="pendingExpirationDate"
:value="computeValueExpiredDate"
v-model="share.expireDate"
class="share-link-expire-date"
:disabled="saving"
:is-native-picker="true"
:hide-label="true"
type="date"
:min="dateTomorrow"
:max="dateMaxEnforced"
@input="share.expireDate = $event">
:max="dateMaxEnforced">
<!-- let's not submit when picked, the user
might want to still edit or copy the password -->
{{ t('files_sharing', 'Enter a date') }}
Expand Down Expand Up @@ -207,7 +206,7 @@
<NcActionCheckbox :checked.sync="hasExpirationDate"
:disabled="config.isDefaultExpireDateEnforced || saving"
class="share-link-expire-date-checkbox"
@uncheck="uncheckExpirationDateCheckbox">
@uncheck="uncheckExpirationDate">
{{ config.isDefaultExpireDateEnforced
? t('files_sharing', 'Expiration date (enforced)')
: t('files_sharing', 'Set expiration date') }}
Expand All @@ -219,7 +218,7 @@
class="share-link-expire-date"
:class="{ error: errors.expireDate}"
:disabled="saving"
:value="computeValueExpiredDate"
:value="expireDate"
type="date"
:min="dateTomorrow"
:max="dateMaxEnforced"
Expand Down Expand Up @@ -359,7 +358,7 @@ export default {

ExternalLegacyLinkActions: OCA.Sharing.ExternalLinkActions.state,
ExternalShareActions: OCA.Sharing.ExternalShareActions.state,
isFirstInitExpiredDate: true,
isFirstInitOfExpireDate: true,
}
},

Expand Down Expand Up @@ -603,15 +602,19 @@ export default {
return this.fileInfo.shareAttributes.some(hasDisabledDownload)
},

computeValueExpiredDate() {
if (this.isFirstInitExpiredDate) {
/**
* Compute value for expiration input field
* @return {Date}
*/
expireDate() {
if (this.isFirstInitOfExpireDate) {
// initial value needs to be set to one day after share.expireDate because the min value of input is dateTomorrow
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.isFirstInitExpiredDate = false
this.isFirstInitOfExpireDate = false
return new Date(new Date().setDate(this.share.expireDate.getDate() + 1))
}
return this.share.expireDate
}
},
},

methods: {
Expand Down Expand Up @@ -873,10 +876,13 @@ export default {
this.$emit('remove:share', this.share)
},

uncheckExpirationDateCheckbox() {
this.isFirstInitExpiredDate = true
/**
* Process unchecking of checkbox for expiration date
*/
uncheckExpirationDate() {
this.isFirstInitOfExpireDate = true
return this.onExpirationDisable()
}
},
},
}
</script>
Expand Down

0 comments on commit 4115f93

Please sign in to comment.