From 431b7921add28c7338785296ca025cfcf6e3c3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Fri, 11 Jan 2019 09:34:21 +0100 Subject: Revert "fix gender field select" --- src/components/ContactDetails.vue | 12 ++++------ .../ContactDetails/ContactDetailsAddNewProp.vue | 2 +- src/components/Properties/PropertySelect.vue | 27 ++++++++++++++++++---- src/mixins/PropertyMixin.js | 5 ++-- src/models/rfcProps.js | 15 ++++++------ 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/components/ContactDetails.vue b/src/components/ContactDetails.vue index 3033f270..a954d01f 100644 --- a/src/components/ContactDetails.vue +++ b/src/components/ContactDetails.vue @@ -103,8 +103,7 @@ empty property because this is a required prop on regular property-select. But since we are hijacking this... (this is supposed to be used with a ICAL.property, but to avoid code duplication, we created a fake propModel and property with our own options here) --> - @@ -273,16 +272,15 @@ export default { /** * Usable addressbook object linked to the local contact * - * @param {string} [addressbook] set the addressbook object + * @param {string} [addressbookId] set the addressbook id * @returns {string} */ addressbook: { get: function() { - return this.addressbooksOptions - .find(addressbook => addressbook.id === this.contact.addressbook.id) + return this.contact.addressbook.id }, - set: function(addressbook) { - this.moveContactToAddressbook(addressbook.id) + set: function(addressbookId) { + this.moveContactToAddressbook(addressbookId) } }, diff --git a/src/components/ContactDetails/ContactDetailsAddNewProp.vue b/src/components/ContactDetails/ContactDetailsAddNewProp.vue index 5ccaa2b5..7562a9a7 100644 --- a/src/components/ContactDetails/ContactDetailsAddNewProp.vue +++ b/src/components/ContactDetails/ContactDetailsAddNewProp.vue @@ -93,7 +93,7 @@ export default { */ addProp({ id }) { let defaultData = rfcProps.properties[id].defaultValue - let property = this.contact.vCard.addPropertyWithValue(id, defaultData && defaultData.value ? defaultData.value : '') + let property = this.contact.vCard.addPropertyWithValue(id, defaultData ? defaultData.value : '') if (defaultData && defaultData.type) { property.setParameter('type', defaultData.type) } diff --git a/src/components/Properties/PropertySelect.vue b/src/components/Properties/PropertySelect.vue index e032363e..51ccd032 100644 --- a/src/components/Properties/PropertySelect.vue +++ b/src/components/Properties/PropertySelect.vue @@ -27,8 +27,13 @@ :info="propModel.info" />
+ +
+ {{ selectType.name }} +
+ -
+
{{ propModel.readableName }}
@@ -36,10 +41,9 @@
@@ -72,10 +76,23 @@ export default { // length is one & add one space at the end return hasTitle + 1 + isLast }, - // is there only one option available isSingleOption() { return this.propModel.options.length <= 1 + }, + + // matching value to the options we provide + matchedOptions: { + get() { + let selected = this.propModel.options.find(option => option.id === this.localValue) + return selected || { + id: this.localValue, + name: this.localValue + } + }, + set(value) { + this.localValue = value.id + } } } } diff --git a/src/mixins/PropertyMixin.js b/src/mixins/PropertyMixin.js index 342eaa75..73b3f21c 100644 --- a/src/mixins/PropertyMixin.js +++ b/src/mixins/PropertyMixin.js @@ -25,7 +25,7 @@ export default { props: { // Default property type. e.g. "WORK,HOME" selectType: { - type: Object, + type: [Object], default: () => {} }, // Coming fro the rfcProps Model @@ -79,8 +79,7 @@ export default { watch: { /** * Since we're updating a local data based on the value prop, - * we need to make sure to update the local data on prop change - * ! this prevent virtual doms to have outdated local data + * we need to make sure to update the local data on pop change */ value: function() { this.localValue = this.value diff --git a/src/models/rfcProps.js b/src/models/rfcProps.js index 397d66f1..122736f2 100644 --- a/src/models/rfcProps.js +++ b/src/models/rfcProps.js @@ -56,6 +56,7 @@ const properties = { readableName: t('contacts', 'Federated Cloud ID'), force: 'text', defaultValue: { + value: [''], type: ['HOME'] }, options: [ @@ -117,6 +118,7 @@ const properties = { icon: 'icon-mail', default: true, defaultValue: { + value: '', type: ['HOME'] }, options: [ @@ -130,6 +132,7 @@ const properties = { readableName: t('contacts', 'Instant messaging'), icon: 'icon-comment', defaultValue: { + value: [''], type: ['SKYPE'] }, options: [ @@ -146,6 +149,7 @@ const properties = { icon: 'icon-phone', default: true, defaultValue: { + value: '', type: ['HOME', 'VOICE'] }, options: [ @@ -172,7 +176,8 @@ const properties = { icon: 'icon-social', readableName: t('contacts', 'Social network'), defaultValue: { - type: ['FACEBOOK'] + value: '', + type: ['facebook'] }, info: t( 'contacts', @@ -203,9 +208,6 @@ const properties = { 'contacts', 'Specify a relationship between you and the entity represented by this vCard.' ), - defaultValue: { - type: ['COLLEAGUE'] - }, options: [ { id: 'SPOUSE', name: t('contacts', 'Spouse') }, { id: 'CHILD', name: t('contacts', 'Child') }, @@ -230,6 +232,7 @@ const properties = { 'Specify a relationship between another entity and the entity represented by this vCard.' ), defaultValue: { + value: [''], type: ['CONTACT'] }, options: [ @@ -253,13 +256,11 @@ const properties = { }, gender: { readableName: t('contacts', 'Gender'), - force: 'select', defaultValue: { // default to Female 🙋 - type: ['F'] + value: ['F'] }, options: [ - // TODO? make X-WAB-GENDER print in VCARD as well for MS compatibility { id: 'F', name: t('contacts', 'Female') }, { id: 'M', name: t('contacts', 'Male') }, { id: 'O', name: t('contacts', 'Other') } -- cgit v1.2.3