summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomohiro Masubuchi <bucchi79@gmail.com>2020-08-08 16:10:17 +0900
committerTomohiro Masubuchi <bucchi79@gmail.com>2020-08-09 20:21:05 +0900
commit59f23ed514cf7c653b779af8dc65e26ec221184e (patch)
tree0194d8afcfc9e8c5b4784043a2afb091dbee03b2 /src
parent8b8a200c5a277ab0d0547947983af3569f3ad7f2 (diff)
Support phonetic name as sort key
Signed-off-by: Tomohiro Masubuchi <bucchi79@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/Settings/SettingsSortContacts.vue8
-rw-r--r--src/models/contact.js31
-rw-r--r--src/store/addressbooks.js3
3 files changed, 41 insertions, 1 deletions
diff --git a/src/components/Settings/SettingsSortContacts.vue b/src/components/Settings/SettingsSortContacts.vue
index 11bf0da3..3b696138 100644
--- a/src/components/Settings/SettingsSortContacts.vue
+++ b/src/components/Settings/SettingsSortContacts.vue
@@ -58,6 +58,14 @@ export default {
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',
},
diff --git a/src/models/contact.js b/src/models/contact.js
index e07fef70..b8324214 100644
--- a/src/models/contact.js
+++ b/src/models/contact.js
@@ -398,6 +398,7 @@ export default class Contact {
if (orderKey && n && !isEmpty(n)) {
switch (orderKey) {
case 'firstName':
+ case 'phoneticFirstName':
// Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
// -> John Stevenson
return n.slice(0, 2).reverse().join(' ')
@@ -460,6 +461,36 @@ export default class Contact {
}
/**
+ * 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
*
* @readonly
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index e81c03ec..d6f89817 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -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