Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support X-PHONETIC-FIRST-NAME and X-PHONETIC-LAST-NAME #1741

Merged
merged 4 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions css/Properties/Properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ $property-ext-padding-right: 8px;
margin-right: 0;
}
}

.property + .property.property-x-phonetic-first-name,
.property + .property.property-x-phonetic-last-name {
margin-top: -40px;
}
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved
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
31 changes: 31 additions & 0 deletions src/models/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ export default class Contact {
if (orderKey && n && !isEmpty(n)) {
switch (orderKey) {
case 'firstName':
case 'phoneticFirstName':
t-bucchi marked this conversation as resolved.
Show resolved Hide resolved
// Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
// -> John Stevenson
return n.slice(0, 2).reverse().join(' ')
Expand Down Expand Up @@ -459,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 @@ -60,6 +60,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 @@ -340,6 +348,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