Skip to content

Commit

Permalink
Merge pull request #1741 from t-bucchi/feature/phonetic-3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Aug 13, 2020
2 parents 752bb14 + b3eec9e commit 2b4c5d7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/Properties/PropertyText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->

<template>
<div v-if="propModel" :class="`grid-span-${gridLength}`" class="property">
<div v-if="propModel" :class="`grid-span-${gridLength} property-${propName}`" class="property">
<!-- title if first element -->
<PropertyTitle v-if="isFirstProperty && propModel.icon"
:icon="propModel.icon"
Expand Down
8 changes: 8 additions & 0 deletions src/components/Settings/SettingsSortContacts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export default {
label: t('contacts', 'Last name'),
key: 'lastName',
},
{
label: t('contacts', 'Phonetic first name'),
key: 'phoneticFirstName',
},
{
label: t('contacts', 'Phonetic last name'),
key: 'phoneticLastName',
},
{
label: t('contacts', 'Display name'),
key: 'displayName',
Expand Down
30 changes: 30 additions & 0 deletions src/models/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,36 @@ export default class Contact {
return this.displayName
}

/**
* Return the phonetic first name if exists
* Returns the first name or displayName otherwise
*
* @readonly
* @memberof Contact
* @returns {string} phoneticFirstName|firstName|displayName
*/
get phoneticFirstName() {
if (this.vCard.hasProperty('x-phonetic-first-name')) {
return this.vCard.getFirstPropertyValue('x-phonetic-first-name')
}
return this.firstName
}

/**
* Return the phonetic last name if exists
* Returns the displayName otherwise
*
* @readonly
* @memberof Contact
* @returns {string} lastName|displayName
*/
get phoneticLastName() {
if (this.vCard.hasProperty('x-phonetic-last-name')) {
return this.vCard.getFirstPropertyValue('x-phonetic-last-name')
}
return this.lastName
}

/**
* Return all the properties as Property objects
*
Expand Down
10 changes: 10 additions & 0 deletions src/models/rfcProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ const properties = {
ActionCopyNtoFN,
],
},
'x-phonetic-first-name': {
readableName: t('contacts', 'Phonetic first name'),
force: 'text',
},
'x-phonetic-last-name': {
readableName: t('contacts', 'Phonetic last name'),
force: 'text',
},
note: {
readableName: t('contacts', 'Notes'),
icon: 'icon-rename',
Expand Down Expand Up @@ -346,6 +354,8 @@ if (locales.length > 0) {
const fieldOrder = [
'org',
'title',
'x-phonetic-first-name',
'x-phonetic-last-name',
'tel',
'email',
'adr',
Expand Down
3 changes: 2 additions & 1 deletion src/store/addressbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ const actions = {
*/
async getContactsFromAddressBook(context, { addressbook }) {
return addressbook.dav
.findAllAndFilterBySimpleProperties(['EMAIL', 'UID', 'CATEGORIES', 'FN', 'ORG', 'N'])
.findAllAndFilterBySimpleProperties(['EMAIL', 'UID', 'CATEGORIES', 'FN', 'ORG', 'N',
'X-PHONETIC-FIRST-NAME', 'X-PHONETIC-LAST-NAME'])
.then((response) => {
// We don't want to lose the url information
// so we need to parse one by one
Expand Down

0 comments on commit 2b4c5d7

Please sign in to comment.