From 1466de563cfb93d5c5db43d59f0e36aee9e3a42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Tue, 2 Apr 2019 13:28:53 +0200 Subject: [PATCH] Remove some properties if empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- src/components/ContactsList/ContactsListItem.vue | 4 ++-- src/models/contact.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/ContactsList/ContactsListItem.vue b/src/components/ContactsList/ContactsListItem.vue index 64a0b62e1..980437038 100644 --- a/src/components/ContactsList/ContactsListItem.vue +++ b/src/components/ContactsList/ContactsListItem.vue @@ -41,8 +41,8 @@
{{ contact.displayName }}
-
diff --git a/src/models/contact.js b/src/models/contact.js index 14ea06ff9..c4eebecc8 100644 --- a/src/models/contact.js +++ b/src/models/contact.js @@ -259,6 +259,12 @@ export default class Contact { * @memberof Contact */ set groups(groups) { + // delete the title if empty + if (isEmpty(groups)) { + this.vCard.removeProperty('categories') + return true + } + if (Array.isArray(groups)) { let property = this.vCard.getFirstProperty('categories') if (!property) { @@ -308,6 +314,10 @@ export default class Contact { * @memberof Contact */ set org(org) { + // delete the org if empty + if (isEmpty(org)) { + return this.vCard.removeProperty('org') + } return this.vCard.updatePropertyWithValue('org', org) } @@ -328,6 +338,10 @@ export default class Contact { * @memberof Contact */ set title(title) { + // delete the title if empty + if (isEmpty(title)) { + return this.vCard.removeProperty('title') + } return this.vCard.updatePropertyWithValue('title', title) }