From d2f266e3b508399ced055970d0345747318bb665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 3 Sep 2018 17:32:33 +0200 Subject: Fix groups parsing and fix add new prop layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .../ContactDetails/ContactDetailsAddNewProp.vue | 2 +- src/models/contact.js | 6 ++--- src/store/FakeName.vcf | 14 ++++++++++- src/store/groups.js | 28 ++++++++++++---------- 4 files changed, 33 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/components/ContactDetails/ContactDetailsAddNewProp.vue b/src/components/ContactDetails/ContactDetailsAddNewProp.vue index 1efcfb43..5d87ceab 100644 --- a/src/components/ContactDetails/ContactDetailsAddNewProp.vue +++ b/src/components/ContactDetails/ContactDetailsAddNewProp.vue @@ -27,7 +27,7 @@
-
{{ t('contacts', 'Add new property') }}
+
contact.groups.map(group => { - // extend group to model - return { - name: group, - contacts: [] - } - })[0]) - // ensure we only have one group of each - state.groups = state.groups.concat(groups) - .filter(function(group, index, self) { - return group && self.findIndex(search => search && search.name === group.name) === index - }) + // iterate on every contacts + .reduce((groups, contact) => { + // transform group names into Object + contact.groups.map(groupName => { + // overriding existing groups: remove duplicates + groups[groupName] = { + name: groupName, + contacts: [] + } + }) + return groups + }, {}) + + // store in state + state.groups = Object.values(groups) + // append keys to groups Object.values(contacts) .forEach(contact => { -- cgit v1.2.3