summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-03 17:32:33 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-03 17:32:33 +0200
commitd2f266e3b508399ced055970d0345747318bb665 (patch)
tree52c07afba3d0f86d687b50871bb0d5d3fad9ad78 /src
parentcf0a8ff7d4cfbaa11db443816c228d164fae61f8 (diff)
Fix groups parsing and fix add new prop layout
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/ContactDetails/ContactDetailsAddNewProp.vue2
-rw-r--r--src/models/contact.js6
-rw-r--r--src/store/FakeName.vcf14
-rw-r--r--src/store/groups.js28
4 files changed, 33 insertions, 17 deletions
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 @@
<property-title :icon="'icon-add'" :readable-name="t('contacts', 'Add new property')" />
<div class="property__row">
- <div class="property__label">{{ t('contacts', 'Add new property') }}</div>
+ <div class="property__label" />
<!-- type selector -->
<multiselect :options="availableProperties" :placeholder="t('contacts', 'Choose property type')" class="multiselect-vue property__value"
diff --git a/src/models/contact.js b/src/models/contact.js
index e5e9e83e..438b1f22 100644
--- a/src/models/contact.js
+++ b/src/models/contact.js
@@ -120,9 +120,9 @@ export default class Contact {
* @memberof Contact
*/
get groups() {
- let prop = this.vCard.getFirstProperty('categories')
- if (prop) {
- return this.vCard.getFirstProperty('categories').getValues()
+ let groupsProp = this.vCard.getFirstProperty('categories')
+ if (groupsProp) {
+ return groupsProp.getValues()
}
return []
}
diff --git a/src/store/FakeName.vcf b/src/store/FakeName.vcf
index c21255de..df963b77 100644
--- a/src/store/FakeName.vcf
+++ b/src/store/FakeName.vcf
@@ -8,6 +8,7 @@ MEMBER:urn:uuid:cd314b39-b71a-41cf-b4eb-5cb61dd6fa24
REV:2017-07-27T05:56:33Z
UID:5acf667e-1cbf-48a8-87fe-546ee31a0b23
END:VCARD
+
BEGIN:VCARD
VERSION:2.1
FN:Jean Dupont
@@ -18,11 +19,12 @@ TEL;CELL:+1234 56789
EMAIL;INTERNET:jean.dupont@example.com
UID:dfs541fds15
END:VCARD
+
BEGIN:VCARD
VERSION:3.0
N:Cunningham;Liam;;Mr.;
FN:Liam Cunningham
-NICKNAME:Begivaing81
+NICKNAME;TYPE=work:Begivaing81
BDAY;VALUE=text:5/26/1981
GENDER:male
ORG:Central Hardware;
@@ -32,6 +34,16 @@ CATEGORIES:Tech,University
TEL;TYPE=VOICE,HOME;VALUE=text:06-22957835
ADR;TYPE=HOME:;;Beilen;DR;9413 BA;Netherlands
END:VCARD
+
+BEGIN:VCARD
+VERSION:4.0
+FN:Simon Perreault
+N:Perreault;Simon;;;ing. jr,M.Sc.
+BDAY:--0203
+ANNIVERSARY:20090808T1430-0500
+GENDER:M
+END:VCARD
+
BEGIN:VCARD
VERSION:3.0
N:Kamiński;Przemysł;;Mr.;
diff --git a/src/store/groups.js b/src/store/groups.js
index 9c3061be..e1ed9721 100644
--- a/src/store/groups.js
+++ b/src/store/groups.js
@@ -35,18 +35,22 @@ const mutations = {
appendGroupsFromContacts(state, contacts) {
// init groups list
let groups = Object.values(contacts)
- .map(contact => 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 => {