Skip to content

Commit

Permalink
feat(2464): exclude contact from birthday calendar
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain <[email protected]>
Co-authored-by: Thomas Citharel <[email protected]>
Co-authored-by: Richard Steinmetz <[email protected]>
  • Loading branch information
3 people committed Oct 11, 2022
1 parent 4575f44 commit e9730d6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -299,6 +308,7 @@ export default {
IconDownload,
IconDelete,
IconQr,
CakeIcon,
IconCopy,
IconLoading,
Modal,
Expand Down Expand Up @@ -338,6 +348,7 @@ export default {
pickedAddressbook: null,

contactDetailsSelector: '.contact-details',
excludeFromBirthdayKey: 'x-nc-exclude-from-birthday-calendar',
}
},

Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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'
*/
Expand Down

0 comments on commit e9730d6

Please sign in to comment.