diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-01-30 11:16:29 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-01-30 12:17:23 +0100 |
commit | a1561dfe3a728f3b636852df05d36c1947883dd7 (patch) | |
tree | 91e90dae3ec08878ae81a2f68a90fba4050ebfc2 /src/models | |
parent | 7af5d37ac8428784843fd3cca531fb30ecf71fe3 (diff) |
Add property-defined actions
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/rfcProps.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/models/rfcProps.js b/src/models/rfcProps.js index 122736f2..79c891e6 100644 --- a/src/models/rfcProps.js +++ b/src/models/rfcProps.js @@ -21,7 +21,17 @@ */ import { VCardTime } from 'ical.js' -const properties = { +const copyNtoFN = ({ contact, updateContact }) => () => { + if (contact.vCard.hasProperty('n')) { + // 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(' ') + updateContact() + } +} + +const properties = component => ({ nickname: { readableName: t('contacts', 'Nickname'), icon: 'icon-user' @@ -39,7 +49,14 @@ const properties = { defaultValue: { value: ['', '', '', '', ''] }, - icon: 'icon-user' + icon: 'icon-user', + actions: [ + { + text: t('contacts', 'Copy to full name'), + icon: 'icon-up', + action: copyNtoFN(component) + } + ] }, note: { readableName: t('contacts', 'Notes'), @@ -266,7 +283,7 @@ const properties = { { id: 'O', name: t('contacts', 'Other') } ] } -} +}) const fieldOrder = [ 'org', |