Animate and fix major structure conflict amongst addressbooks

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-10-24 12:44:50 +02:00
parent 42ac987d96
commit ffb098c0ee
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
5 changed files with 21 additions and 7 deletions

View File

@ -13,4 +13,13 @@
[class*='--pulse '],
[class$='--pulse'] {
animation: pulse 1.5s infinite;
}
.list-enter-active, .list-leave-active {
transition: all 500ms ease-in-out;
}
.list-enter,
.list-leave-to {
opacity: 0;
}

View File

@ -217,7 +217,7 @@ export default {
href: this.contact.url
}
]
if (this.contact.addressbook.readOnly) {
if (!this.contact.addressbook.readOnly) {
actions.push({
icon: 'icon-delete',
text: t('contacts', 'Delete'),

View File

@ -21,12 +21,13 @@
-->
<template>
<div id="contacts-list" :class="{'icon-loading': loading}" class="app-content-list">
<transition-group id="contacts-list" :class="{'icon-loading': loading}" class="app-content-list"
name="list" tag="div">
<!-- same uid can coexists between different addressbooks
so we need to use the addressbook id as key as well -->
<content-list-item v-for="contact in list" :key="contact.key" :contact="contacts[contact.key]"
:search-query="searchQuery" />
</div>
</transition-group>
</template>
<script>

View File

@ -15,7 +15,7 @@
</div>
<div class="app-content-list-item-line-one">{{ contact.displayName }}</div>
<div v-if="contact.email" class="app-content-list-item-line-two">{{ contact.email }}</div>
<div v-if="contact.addressbook.readOnly" class="icon-delete" tabindex="0"
<div v-if="!contact.addressbook.readOnly" class="icon-delete" tabindex="0"
@click.prevent.stop="deleteContact" @keypress.enter.prevent.stop="deleteContact" />
</div>
</template>

View File

@ -73,7 +73,11 @@ const mutations = {
*/
addAddressbook(state, addressbook) {
// extend the addressbook to the default model
state.addressbooks.push(Object.assign({}, addressbookModel, addressbook))
addressbook = Object.assign({}, addressbookModel, addressbook)
// force reinit of the contacts object to prevent
// data passed as references
addressbook.contacts = {}
state.addressbooks.push(addressbook)
},
/**
@ -118,7 +122,7 @@ const mutations = {
* @param {Contact[]} data.contacts array of contacts to append
*/
appendContactsToAddressbook(state, { addressbook, contacts }) {
addressbook = state.addressbooks.find(search => search === addressbook)
addressbook = state.addressbooks.find(search => search.id === addressbook.id)
// convert list into an array and remove duplicate
addressbook.contacts = contacts.reduce((list, contact) => {
@ -317,7 +321,7 @@ const actions = {
.then((response) => {
// We don't want to lose the url information
// so we need to parse one by one
const contacts = response.map(item => {
let contacts = response.map(item => {
let contact = new Contact(item.data, addressbook)
Vue.set(contact, 'dav', item)
return contact