diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-24 10:50:27 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-24 12:06:10 +0200 |
commit | 42ac987d961441c0413c47d384373476cc8cc833 (patch) | |
tree | 92fec8287cdf1a0d1cdc0f1c719ecd190f2731f8 | |
parent | 000f3ae886a67639e2a44fe82fd463f89f09ff8f (diff) |
Fix enable ab toggle
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
-rw-r--r-- | css/ImportScreen.scss (renamed from css/importScreen.scss) | 0 | ||||
-rw-r--r-- | css/Settings/SettingsAddressbook.scss | 3 | ||||
-rw-r--r-- | css/contacts.scss | 6 | ||||
-rw-r--r-- | src/components/Settings/SettingsAddressbook.vue | 2 | ||||
-rw-r--r-- | src/store/addressbooks.js | 12 | ||||
-rw-r--r-- | src/views/Contacts.vue | 15 |
6 files changed, 25 insertions, 13 deletions
diff --git a/css/importScreen.scss b/css/ImportScreen.scss index 3d815389..3d815389 100644 --- a/css/importScreen.scss +++ b/css/ImportScreen.scss diff --git a/css/Settings/SettingsAddressbook.scss b/css/Settings/SettingsAddressbook.scss index b5d779c0..61796c76 100644 --- a/css/Settings/SettingsAddressbook.scss +++ b/css/Settings/SettingsAddressbook.scss @@ -48,4 +48,7 @@ &__share { margin-left: auto; } + &--disabled &__name { + opacity: .5; + } }
\ No newline at end of file diff --git a/css/contacts.scss b/css/contacts.scss index e963e361..a54e58f8 100644 --- a/css/contacts.scss +++ b/css/contacts.scss @@ -37,7 +37,7 @@ $grid-input-height-with-margin: #{$grid-height-unit - $grid-input-margin * 2}; } } - +// components @import 'SettingsSection'; @import 'Settings/SettingsAddressbook'; @import 'Settings/SettingsAddressbookShares'; @@ -47,6 +47,8 @@ $grid-input-height-with-margin: #{$grid-height-unit - $grid-input-margin * 2}; @import 'ContentListItem'; @import 'Properties/Properties'; @import 'Properties/PropertyTitle'; -@import 'importScreen'; +@import 'ImportScreen'; + +// various @import 'animations'; @import 'icons'; diff --git a/src/components/Settings/SettingsAddressbook.vue b/src/components/Settings/SettingsAddressbook.vue index cff0c24b..2edac4e6 100644 --- a/src/components/Settings/SettingsAddressbook.vue +++ b/src/components/Settings/SettingsAddressbook.vue @@ -22,7 +22,7 @@ --> <template> <div> - <li :class="{disabled: !addressbook.enabled}" class="addressbook"> + <li :class="{'addressbook--disabled': !addressbook.enabled}" class="addressbook"> <!-- addressbook name --> <span class="addressbook__name">{{ addressbook.displayName }}</span> <!-- sharing button --> diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js index 3c745c95..84a0d79b 100644 --- a/src/store/addressbooks.js +++ b/src/store/addressbooks.js @@ -57,7 +57,7 @@ export function mapDavCollectionToAddressbook(addressbook) { displayName: addressbook.displayname, enabled: addressbook.enabled !== false, owner: addressbook.owner, - readOnly: addressbook.readOnly !== false, + readOnly: addressbook.readOnly === true, url: addressbook.url, dav: addressbook } @@ -278,9 +278,15 @@ const actions = { * @returns {Promise} */ async toggleAddressbookEnabled(context, addressbook) { - addressbook.dav.enabled = !addressbook.dav.enabled + addressbook.dav.enabled = !addressbook.enabled return addressbook.dav.update() - .then((response) => context.commit('toggleAddressbookEnabled', addressbook)) + .then((response) => { + context.commit('toggleAddressbookEnabled', addressbook) + if (addressbook.enabled && Object.values(addressbook.contacts).length === 0) { + context.dispatch('getContactsFromAddressBook', { addressbook }) + } + + }) .catch((error) => { throw error }) }, diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue index a769f209..67a7fa39 100644 --- a/src/views/Contacts.vue +++ b/src/views/Contacts.vue @@ -282,13 +282,14 @@ export default { */ fetchContacts() { // wait for all addressbooks to have fetch their contacts - Promise.all(this.addressbooks.map(addressbook => this.$store.dispatch('getContactsFromAddressBook', { addressbook }))) - .then(results => { - this.loading = false - this.selectFirstContactIfNone() - }) - // no need for a catch, the action does not throw - // and the error is handled there + Promise.all(this.addressbooks.map(addressbook => { + if (addressbook.enabled) { + return this.$store.dispatch('getContactsFromAddressBook', { addressbook }) + } + })).then(results => { + this.loading = false + this.selectFirstContactIfNone() + }) }, /** |