summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2019-01-11 12:04:51 +0100
committerGitHub <noreply@github.com>2019-01-11 12:04:51 +0100
commit131667f5fdf3d830084603da37590956a7c15424 (patch)
treeed7ccb3a749b730db2050418c8b4812f1be61c9a
parentca15bd09e5c700b26f3020555ccf5a26bd26291e (diff)
parent431b7921add28c7338785296ca025cfcf6e3c3e0 (diff)
Merge pull request #846 from nextcloud/revert-825-gender
Revert "fix gender field select"
-rw-r--r--src/components/ContactDetails.vue12
-rw-r--r--src/components/ContactDetails/ContactDetailsAddNewProp.vue2
-rw-r--r--src/components/Properties/PropertySelect.vue27
-rw-r--r--src/mixins/PropertyMixin.js5
-rw-r--r--src/models/rfcProps.js15
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) -->
- <property-select :prop-model="addressbookModel" :select-type.sync="addressbook" value=""
- :is-first-property="true"
+ <property-select :prop-model="addressbookModel" :value.sync="addressbook" :is-first-property="true"
:is-last-property="true" :property="{}" class="property--addressbooks property--last" />
<!-- Groups always visible -->
@@ -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" />
<div class="property__row">
+ <!-- if we do not support any type on our model but one is set anyway -->
+ <div v-if="selectType" class="property__label">
+ {{ selectType.name }}
+ </div>
+
<!-- no options, empty space -->
- <div class="property__label">
+ <div v-else class="property__label">
{{ propModel.readableName }}
</div>
@@ -36,10 +41,9 @@
<button v-if="!isReadOnly" :title="t('contacts', 'Delete')" class="property__delete icon-delete"
@click="deleteProperty" />
- <multiselect v-model="localType"
- :options="propModel.options" :searchable="false" :placeholder="t('contacts', 'Select option')"
+ <multiselect v-model="matchedOptions" :options="propModel.options" :placeholder="t('contacts', 'Select option')"
:disabled="isSingleOption || isReadOnly" class="property__value" track-by="id"
- label="name" @input="updateType" />
+ label="name" @input="updateValue" />
</div>
</div>
</template>
@@ -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') }