diff options
author | Bastien PROMPSY <bastienprompsy@gmail.com> | 2022-05-12 11:52:16 +0200 |
---|---|---|
committer | Bastien PROMPSY <bastienprompsy@gmail.com> | 2022-05-12 11:54:10 +0200 |
commit | 310c5c94a256dfdd534ae44b5d2c8c5a71e03a41 (patch) | |
tree | b8dc69cbbaa27b746e84b83928a1ef937c35cd4b /src | |
parent | 53390f4d0da40377abee60413e408162c170233d (diff) |
Make sure all the fiels are blank when a new contact is created
Duplicate the default value before replacing it if it's an array
Signed-off-by: Bastien PROMPSY <bastienprompsy@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ContactDetails/ContactDetailsAddNewProp.vue | 6 | ||||
-rw-r--r-- | src/views/Contacts.vue | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/components/ContactDetails/ContactDetailsAddNewProp.vue b/src/components/ContactDetails/ContactDetailsAddNewProp.vue index 7774b192..aafdfd7c 100644 --- a/src/components/ContactDetails/ContactDetailsAddNewProp.vue +++ b/src/components/ContactDetails/ContactDetailsAddNewProp.vue @@ -116,7 +116,11 @@ export default { this.contact.vCard.addProperty(property) } else { const defaultData = this.properties[id].defaultValue - const property = this.contact.vCard.addPropertyWithValue(id, defaultData ? defaultData.value : '') + let defaultValue = defaultData ? defaultData.value : '' + if (Array.isArray(defaultValue)) { + defaultValue = [...defaultValue] + } + const property = this.contact.vCard.addPropertyWithValue(id, defaultValue) if (defaultData && defaultData.type) { property.setParameter('type', defaultData.type) } diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue index 78420b38..b323674c 100644 --- a/src/views/Contacts.vue +++ b/src/views/Contacts.vue @@ -275,8 +275,12 @@ export default { for (const name in properties) { if (properties[name].default) { const defaultData = properties[name].defaultValue + let defaultValue = defaultData.value + if (Array.isArray(defaultValue)) { + defaultValue = [...defaultValue] + } // add default field - const property = contact.vCard.addPropertyWithValue(name, defaultData.value) + const property = contact.vCard.addPropertyWithValue(name, defaultValue) // add default type if (defaultData.type) { property.setParameter('type', defaultData.type) |