diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-03-27 22:27:50 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-03-27 22:27:50 +0100 |
commit | 856513972c65e3fc1775c368a8728102ad3752ad (patch) | |
tree | 87151b1d5874276912bec133ef4ca50374e45cc3 /src | |
parent | f67a5cc9b3bea0a0308e0dec7f804ebb32485618 (diff) |
Properly save and update existing custom labels
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ContactDetails/ContactDetailsProperty.vue | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/components/ContactDetails/ContactDetailsProperty.vue b/src/components/ContactDetails/ContactDetailsProperty.vue index 568aa554..1d7d9fd1 100644 --- a/src/components/ContactDetails/ContactDetailsProperty.vue +++ b/src/components/ContactDetails/ContactDetailsProperty.vue @@ -188,6 +188,15 @@ export default { }, /** + * Return the associated X-ABLABEL if any + * + * @returns {Property} + */ + propLabel() { + return this.contact.vCard.getFirstProperty(`${this.propGroup[0]}.x-ablabel`) + }, + + /** * Returns the closest match to the selected type * or return the default selected as a new object if * none exists @@ -197,11 +206,10 @@ export default { selectType: { get() { // ! if ABLABEL is present, this is a priority - const type = this.contact.vCard.getFirstPropertyValue(`${this.propGroup[0]}.x-ablabel`) - if (type) { + if (this.propLabel) { return { - id: type, - name: type + id: this.propLabel.name, + name: this.propLabel.getFirstValue() } } if (this.propModel && this.propModel.options && this.type) { @@ -243,8 +251,17 @@ export default { return null }, set(data) { - // ical.js take types as arrays - this.type = data.id.split(',') + // if a custom label exists and this is the one we selected + if (this.propLabel && data.id === this.propLabel.name) { + this.propLabel.setValue(data.name) + // only one can coexist + this.type = [] + } else { + // ical.js take types as arrays + this.type = data.id.split(',') + // only one can coexist + this.contact.vCard.removeProperty(`${this.propGroup[0]}.x-ablabel`) + } this.$emit('updatedcontact') } |