From 145babb087c1d827e2049a05dfcaa6535fb8c3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 24 Sep 2018 15:27:29 +0200 Subject: Add addressbook dav MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- src/components/Settings/SettingsNewAddressbook.vue | 35 ++++++++++++---------- src/models/contact.js | 8 +++-- src/store/contacts.js | 12 ++++++-- 3 files changed, 34 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/components/Settings/SettingsNewAddressbook.vue b/src/components/Settings/SettingsNewAddressbook.vue index ea026526..9c1c66ac 100644 --- a/src/components/Settings/SettingsNewAddressbook.vue +++ b/src/components/Settings/SettingsNewAddressbook.vue @@ -21,15 +21,14 @@ --> @@ -47,11 +46,8 @@ export default { data() { return { // TODO: add pattern attribute to input, bind to addressBookRegex property - } - }, - computed: { - menu() { - return [] + loading: false, + displayName: '' } }, methods: { @@ -59,8 +55,17 @@ export default { * Add a new address book */ addAddressbook() { - let addressbook = this.$refs.addressbook.value - this.$store.dispatch('appendAddressbook', { displayName: addressbook }) + this.loading = true + this.$store.dispatch('appendAddressbook', { displayName: this.displayName }) + .then(() => { + this.displayName = '' + this.loading = false + }) + .catch((error) => { + console.error(error) + OC.Notification.showTemporary(t('contacts', 'An error occurred, unable to create the addressbook.')) + this.loading = false + }) } } } diff --git a/src/models/contact.js b/src/models/contact.js index e23fffff..9dc6ced5 100644 --- a/src/models/contact.js +++ b/src/models/contact.js @@ -232,9 +232,11 @@ export default class Contact { } if (this.vCard.hasProperty('n')) { // reverse and join - return this.vCard.getFirstPropertyValue('n').filter(function(part) { - return part - }).join(' ') + return this.vCard.getFirstPropertyValue('n') + .filter(function(part) { + return part + }) + .join(' ') } return null } diff --git a/src/store/contacts.js b/src/store/contacts.js index 81432343..c1d7ecb9 100644 --- a/src/store/contacts.js +++ b/src/store/contacts.js @@ -193,7 +193,7 @@ const actions = { /** * Delete a contact from the list and from the associated addressbook * - * @param {Object} state + * @param {Object} context * @param {Contact} contact the contact to delete */ deleteContact(context, contact) { @@ -211,7 +211,7 @@ const actions = { /** * Add a contact to the list and to the associated addressbook * - * @param {Object} state + * @param {Object} context * @param {Contact} contact the contact to delete */ addContact(context, contact) { @@ -227,7 +227,7 @@ const actions = { /** * Replac a contact by this new object * - * @param {Object} state + * @param {Object} context * @param {Contact} contact the contact to update */ updateContact(context, contact) { @@ -237,6 +237,12 @@ const actions = { .catch((error) => { throw error }) }, + /** + * Fetch the full vCard from the dav server + * + * @param {Object} context + * @param {Contact} contact the contact to fetch + */ fetchFullContact(context, contact) { return contact.dav.fetchCompleteData() .then(() => { -- cgit v1.2.3