summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-21 20:05:53 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-25 14:52:43 +0200
commit7b339ebdc3fc11641d10a15f99899f0c1793828e (patch)
treec1801f13ed07f84863f60dab6b2c370501d18eab /src
parentba72cdbadf5b44fe99aef97c060ce88cbad6445e (diff)
Contact save and loader
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/ContactDetails.vue30
-rw-r--r--src/store/addressbooks.js13
-rw-r--r--src/store/contacts.js5
3 files changed, 32 insertions, 16 deletions
diff --git a/src/components/ContactDetails.vue b/src/components/ContactDetails.vue
index a313923b..f3c4b647 100644
--- a/src/components/ContactDetails.vue
+++ b/src/components/ContactDetails.vue
@@ -71,9 +71,12 @@
<!-- actions -->
<div id="contact-header-actions">
- <div v-click-outside="closeMenu" class="menu-icon icon-more-white" @click="toggleMenu" />
- <div :class="{ 'open': openedMenu }" class="popovermenu">
- <popover-menu :menu="contactActions" />
+ <div :class="{'icon-loading-small': loadingUpdate}" class="menu-icon" />
+ <div class="menu-icon">
+ <div v-click-outside="closeMenu" class="icon-more-white" @click="toggleMenu" />
+ <div :class="{ 'open': openedMenu }" class="popovermenu">
+ <popover-menu :menu="contactActions" />
+ </div>
</div>
</div>
</header>
@@ -154,6 +157,7 @@ export default {
*/
localContact: undefined,
loadingData: true,
+ loadingUpdate: false,
openedMenu: false,
addressbookModel: {
readableName: t('contacts', 'Addressbook'),
@@ -242,7 +246,16 @@ export default {
}
},
+ watch: {
+ contact: function() {
+ if (this.uid) {
+ this.selectContact(this.uid)
+ }
+ }
+ },
+
beforeMount() {
+ // load the desired data if we already selected a contact
if (this.uid) {
this.selectContact(this.uid)
}
@@ -254,7 +267,11 @@ export default {
* Send the local clone of contact to the store
*/
updateContact() {
+ this.loadingUpdate = true
this.$store.dispatch('updateContact', this.contact)
+ .then(() => {
+ this.loadingUpdate = false
+ })
},
/**
@@ -325,13 +342,6 @@ export default {
})
}
}
- },
- watch: {
- contact: function() {
- if (this.uid) {
- this.selectContact(this.uid)
- }
- }
}
}
</script>
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index bc61b982..59a8b64a 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -358,13 +358,16 @@ const actions = {
*
* @param {Object} context
* @param {Object} data
- * @param {Contact} data.contact
- * @param {Object} data.addressbook
+ * @param {Contact} data.contact the contact to move
+ * @param {Object} data.addressbook the addressbook to move the contact to
*/
moveContactToAddressbook(context, { contact, addressbook }) {
- context.commit('deleteContactFromAddressbook', contact)
- context.commit('updateContactAddressbook', { contact, addressbook })
- context.commit('addContactToAddressbook', contact)
+ contact.dav.move(addressbook.dav)
+ .then(() => {
+ context.commit('deleteContactFromAddressbook', contact)
+ context.commit('updateContactAddressbook', { contact, addressbook })
+ context.commit('addContactToAddressbook', contact)
+ })
}
}
diff --git a/src/store/contacts.js b/src/store/contacts.js
index e937af83..81432343 100644
--- a/src/store/contacts.js
+++ b/src/store/contacts.js
@@ -231,7 +231,10 @@ const actions = {
* @param {Contact} contact the contact to update
*/
updateContact(context, contact) {
- context.commit('updateContact', contact)
+ contact.dav.data = ICAL.stringify(contact.vCard.jCal)
+ return contact.dav.update()
+ .then((response) => context.commit('updateContact', contact))
+ .catch((error) => { throw error })
},
fetchFullContact(context, contact) {