Skip to content

Commit

Permalink
Add ABLABEL and ITEMX.property support
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv committed Mar 27, 2019
1 parent ae80cf1 commit 14b940e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/components/ContactDetails/ContactDetailsProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export default {
* @returns {string}
*/
propName() {
// ! is this a ITEMXX.XXX property??
if (this.propGroup[1]) {
return this.propGroup[1]
}

return this.property.name
},
/**
Expand All @@ -139,7 +144,16 @@ export default {
if (this.propModel && this.propModel.force) {
return this.propModel.force
}
return this.property.getDefaultType()

// ! is this a ITEMXX.XXX property??
const defaultType = this.property.getDefaultType()
if (defaultType === 'unknown'
&& this.properties[this.propName]
&& this.property._designSet.property[this.propName]) {
return this.property._designSet.property[this.propName].defaultType
}

return defaultType
},

/**
Expand Down Expand Up @@ -171,6 +185,24 @@ export default {
return []
},

/**
* Return the id and type of a property group
* e.g ITEMXX.tel => ['ITEMXX', 'tel']
*
* @returns {Array}
*/
propGroup() {
const defaultType = this.property.getDefaultType()
if (defaultType === 'unknown') {
// splitting and checking validity of last part
const type = this.property.name.split('.')
if (type.length === 2) {
return type
}
}
return []
},

/**
* Returns the closest match to the selected type
* or return the default selected as a new object if
Expand All @@ -180,6 +212,14 @@ export default {
*/
selectType: {
get() {
// ! if ABLABEL is present, this is a priority
const type = this.contact.vCard.getFirstPropertyValue(`${this.propGroup[0]}.x-ablabel`)
if (type) {
return {
id: type,
name: type
}
}
if (this.propModel && this.propModel.options && this.type) {

let selectedType = this.type
Expand Down

0 comments on commit 14b940e

Please sign in to comment.