diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2022-10-11 13:06:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 13:06:25 +0300 |
commit | 68b15a33184b4e85531097d23895cae2f465f64c (patch) | |
tree | 9910e4443e64194f47e759444d6037b2e24132dd | |
parent | e32f12d63441de674e82b89835d73dcb76829917 (diff) | |
parent | e9730d6b425cf30a6345685af9f987b166d4a16c (diff) |
Merge pull request #3009 from sylvainmetayer/feat_2464_exclude_contact_from_birthday_calendar
feat(2464): exclude contact from birthday calendar
-rw-r--r-- | src/components/ContactDetails.vue | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/components/ContactDetails.vue b/src/components/ContactDetails.vue index 97aaf610..e333ea43 100644 --- a/src/components/ContactDetails.vue +++ b/src/components/ContactDetails.vue @@ -139,6 +139,14 @@ </template> {{ t('contacts', 'Generate QR Code') }} </ActionButton> + <ActionButton v-if="enableToggleBirthdayExclusion" + :close-after-click="true" + @click="toggleBirthdayExclusionForContact"> + <template #icon> + <CakeIcon :size="20" /> + </template> + {{ excludeFromBirthdayLabel }} + </ActionButton> <ActionButton v-if="!isReadOnly" @click="deleteContact"> <template #icon> <IconDelete :size="20" /> @@ -267,6 +275,7 @@ import IconLoading from '@nextcloud/vue/dist/Components/NcLoadingIcon' import IconDownload from 'vue-material-design-icons/Download' import IconDelete from 'vue-material-design-icons/Delete' import IconQr from 'vue-material-design-icons/Qrcode' +import CakeIcon from 'vue-material-design-icons/Cake' import IconCopy from 'vue-material-design-icons/ContentCopy' import rfcProps from '../models/rfcProps' @@ -299,6 +308,7 @@ export default { IconDownload, IconDelete, IconQr, + CakeIcon, IconCopy, IconLoading, Modal, @@ -338,6 +348,7 @@ export default { pickedAddressbook: null, contactDetailsSelector: '.contact-details', + excludeFromBirthdayKey: 'x-nc-exclude-from-birthday-calendar', } }, @@ -502,6 +513,16 @@ export default { contact() { return this.$store.getters.getContact(this.contactKey) }, + + excludeFromBirthdayLabel() { + return this.localContact.vCard.hasProperty(this.excludeFromBirthdayKey) + ? t('contacts', 'Add contact to Birthday Calendar') + : t('contacts', 'Exclude contact from Birthday Calendar') + }, + + enableToggleBirthdayExclusion() { + return parseInt(OC.config.version.split('.')[0]) >= 26 + }, }, watch: { @@ -576,6 +597,16 @@ export default { } }, + async toggleBirthdayExclusionForContact() { + if (!this.localContact.vCard.hasProperty(this.excludeFromBirthdayKey)) { + this.localContact.vCard.addPropertyWithValue(this.excludeFromBirthdayKey, true) + } else { + this.localContact.vCard.removeProperty(this.excludeFromBirthdayKey) + } + + await this.updateContact() + }, + /** * Select the text in the input if it is still set to 'new Contact' */ |