summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/ContactDetails/ContactDetailsAddNewProp.vue17
-rw-r--r--src/components/ContactDetails/ContactDetailsAvatar.vue12
-rw-r--r--src/components/ContactDetails/ContactDetailsProperty.vue8
-rw-r--r--src/components/ContactsList/ContactsListItem.vue2
-rw-r--r--src/components/Properties/PropertyText.vue2
-rw-r--r--src/mixins/PropertyMixin.js4
-rw-r--r--src/models/contact.js2
-rw-r--r--src/services/checks/missingFN.js21
-rw-r--r--src/services/validate.js20
-rw-r--r--src/store/contacts.js2
-rw-r--r--src/views/Contacts.vue7
11 files changed, 60 insertions, 37 deletions
diff --git a/src/components/ContactDetails/ContactDetailsAddNewProp.vue b/src/components/ContactDetails/ContactDetailsAddNewProp.vue
index 7562a9a7..fc8e824d 100644
--- a/src/components/ContactDetails/ContactDetailsAddNewProp.vue
+++ b/src/components/ContactDetails/ContactDetailsAddNewProp.vue
@@ -55,6 +55,15 @@ export default {
},
computed: {
+
+ /**
+ * Rfc props scoped
+ * @returns {Object}
+ */
+ properties() {
+ return rfcProps.properties(this)
+ },
+
/**
* List of properties that the contact already have
*
@@ -71,14 +80,14 @@ export default {
* @returns {Object[]}
*/
availableProperties() {
- return Object.keys(rfcProps.properties)
+ return Object.keys(this.properties)
// only allow to add multiple properties OR props that are not yet in the contact
- .filter(key => rfcProps.properties[key].multiple || this.usedProperties.indexOf(key) === -1)
+ .filter(key => this.properties[key].multiple || this.usedProperties.indexOf(key) === -1)
// usable array of objects
.map(key => {
return {
id: key,
- name: rfcProps.properties[key].readableName
+ name: this.properties[key].readableName
}
}).sort((a, b) => a.name.localeCompare(b.name))
}
@@ -92,7 +101,7 @@ export default {
* @param {string} data.id the id of the property. e.g fn
*/
addProp({ id }) {
- let defaultData = rfcProps.properties[id].defaultValue
+ let defaultData = this.properties[id].defaultValue
let property = this.contact.vCard.addPropertyWithValue(id, defaultData ? defaultData.value : '')
if (defaultData && defaultData.type) {
property.setParameter('type', defaultData.type)
diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue
index 8afa46d2..fccbd25f 100644
--- a/src/components/ContactDetails/ContactDetailsAvatar.vue
+++ b/src/components/ContactDetails/ContactDetailsAvatar.vue
@@ -1,10 +1,10 @@
<!--
-import rfcProps from '../../models/rfcProps';
- * @copyright Copyright (c) 2018 Team Popcorn <teampopcornberlin@gmail.com>
- *
- * @author Team Popcorn <teampopcornberlin@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
+ - @copyright Copyright (c) 2018 Team Popcorn <teampopcornberlin@gmail.com>
+ -
+ - @author Team Popcorn <teampopcornberlin@gmail.com>
+ - @author John Molakvoæ <skjnldsv@protonmail.com>
+ -
+ - @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
diff --git a/src/components/ContactDetails/ContactDetailsProperty.vue b/src/components/ContactDetails/ContactDetailsProperty.vue
index 35db5032..cfe5abe2 100644
--- a/src/components/ContactDetails/ContactDetailsProperty.vue
+++ b/src/components/ContactDetails/ContactDetailsProperty.vue
@@ -89,8 +89,10 @@ export default {
},
// rfc properties list
+ // passing this to properties to allow us to scope the properties object
+ // this make possible defining actions there
properties() {
- return rfcProps.properties
+ return rfcProps.properties(this)
},
fieldOrder() {
return rfcProps.fieldOrder
@@ -147,9 +149,7 @@ export default {
* @returns {Object}
*/
propModel() {
- // passing this to properties to allow us to scope the properties object
- // this make possible defining actions there
- return this.properties(this)[this.propName]
+ return this.properties[this.propName]
},
/**
diff --git a/src/components/ContactsList/ContactsListItem.vue b/src/components/ContactsList/ContactsListItem.vue
index 78ff1ea0..60086c4a 100644
--- a/src/components/ContactsList/ContactsListItem.vue
+++ b/src/components/ContactsList/ContactsListItem.vue
@@ -65,7 +65,7 @@ export default {
* @returns {boolean}
*/
matchSearch() {
- if (this.searchQuery !== '') {
+ if (this.searchQuery.trim() !== '') {
return this.contact.searchData.toString().toLowerCase().search(this.searchQuery.toLowerCase()) !== -1
}
return true
diff --git a/src/components/Properties/PropertyText.vue b/src/components/Properties/PropertyText.vue
index 447775ab..106ccf2b 100644
--- a/src/components/Properties/PropertyText.vue
+++ b/src/components/Properties/PropertyText.vue
@@ -147,7 +147,7 @@ export default {
},
haveExtHandler() {
- return this.externalHandler !== '' && this.value && this.value.length > 0
+ return this.externalHandler.trim() !== '' && this.value && this.value.length > 0
}
},
diff --git a/src/mixins/PropertyMixin.js b/src/mixins/PropertyMixin.js
index cdb166f2..b1070bcc 100644
--- a/src/mixins/PropertyMixin.js
+++ b/src/mixins/PropertyMixin.js
@@ -28,7 +28,7 @@ export default {
type: [Object],
default: () => {}
},
- // Coming fro the rfcProps Model
+ // Coming from the rfcProps Model
propModel: {
type: Object,
default: () => {},
@@ -83,7 +83,7 @@ export default {
icon: 'icon-delete',
action: this.deleteProperty
}
- return [del, ...this.propModel.actions ? this.propModel.actions : []]
+ return [...this.propModel.actions ? this.propModel.actions : [], del]
}
},
diff --git a/src/models/contact.js b/src/models/contact.js
index 6510edb8..d284e7fc 100644
--- a/src/models/contact.js
+++ b/src/models/contact.js
@@ -178,7 +178,7 @@ export default class Contact {
let groupsProp = this.vCard.getFirstProperty('categories')
if (groupsProp) {
return groupsProp.getValues()
- .filter(group => group !== '')
+ .filter(group => group.trim() !== '')
}
return []
}
diff --git a/src/services/checks/missingFN.js b/src/services/checks/missingFN.js
index 449f4a43..86a92c7a 100644
--- a/src/services/checks/missingFN.js
+++ b/src/services/checks/missingFN.js
@@ -30,8 +30,9 @@ export default {
return !contact.vCard.hasProperty('fn') // No FN
|| contact.vCard.getFirstPropertyValue('fn') === '' // Empty FN
|| ( // we don't want to fix newly created contacts
- contact.dav // Existing contact
- && contact.vCard.getFirstPropertyValue('fn') === t('contacts', 'New contact') // AND Unchanged FN
+ contact.dav // Existing contact
+ && contact.vCard.getFirstPropertyValue('fn')
+ .toLowerCase() === t('contacts', 'New contact').toLowerCase() // AND Unchanged FN
)
},
fix: contact => {
@@ -39,14 +40,22 @@ export default {
// Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
// -> John Stevenson
const n = contact.vCard.getFirstPropertyValue('n')
- contact.fullName = n.slice(0, 2).reverse().join(' ')
- return true
+ const fullName = n.slice(0, 2).reverse().join(' ')
+ if (fullName.trim() !== '') {
+ contact.fullName = fullName
+ return true
+ }
+ return false
} else if (contact.vCard.hasProperty('org')) {
const org = contact.vCard.getFirstPropertyValue('org')
// ABC, Inc.;North American Division;Marketing
// -> ABC, Inc.
- contact.fullName = org[0]
- return true
+ const fullName = org[0]
+ if (fullName.trim() !== '') {
+ contact.fullName = fullName
+ return true
+ }
+ return false
}
return false
}
diff --git a/src/services/validate.js b/src/services/validate.js
index be080988..c80542f9 100644
--- a/src/services/validate.js
+++ b/src/services/validate.js
@@ -28,16 +28,20 @@ export default function(contact) {
// Going through every checks
checks.forEach(check => {
- if (check.run(contact)) {
+ try {
+ if (check.run(contact)) {
- // A fix is needed, running ⏳
- if (!check.fix(contact)) {
- // FAILURE 🙅
- console.warn('The following contact needed a correction that failed:', check.name, contact)
- } else {
- // SUCCESS 💪
- console.info('The following contact has been repaired:', check.name, contact)
+ // A fix is needed, running ⏳
+ if (!check.fix(contact)) {
+ // FAILURE 🙅
+ console.warn('The following contact needed a correction that failed:', check.name, contact)
+ } else {
+ // SUCCESS 💪
+ console.info('The following contact has been repaired:', check.name, contact)
+ }
}
+ } catch (error) {
+ console.error('Error during the check:', check.name, contact, error)
}
})
diff --git a/src/store/contacts.js b/src/store/contacts.js
index d5538b6e..613fd2a9 100644
--- a/src/store/contacts.js
+++ b/src/store/contacts.js
@@ -331,7 +331,7 @@ const actions = {
* @returns {Promise}
*/
async fetchFullContact(context, { contact, etag = '' }) {
- if (etag !== '') {
+ if (etag.trim() !== '') {
await context.commit('updateContactEtag', { contact, etag })
}
return contact.dav.fetchCompleteData()
diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue
index 894389fd..4e99bb27 100644
--- a/src/views/Contacts.vue
+++ b/src/views/Contacts.vue
@@ -261,11 +261,12 @@ export default {
methods: {
async newContact() {
let contact = new Contact('BEGIN:VCARD\nVERSION:4.0\nEND:VCARD', this.defaultAddressbook)
+ const properties = rfcProps.properties(this)
contact.fullName = t('contacts', 'New contact')
// itterate over all properties (filter is not usable on objects and we need the key of the property)
- for (let name in rfcProps.properties) {
- if (rfcProps.properties[name].default) {
- let defaultData = rfcProps.properties[name].defaultValue
+ for (let name in properties) {
+ if (properties[name].default) {
+ let defaultData = properties[name].defaultValue
// add default field
let property = contact.vCard.addPropertyWithValue(name, defaultData.value)
// add default type