summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-27 19:00:17 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-27 19:00:40 +0200
commitfde4ba27f4356b220857e17ca9c358c76b81aec1 (patch)
treeda292b9181ce79815fecdd3fd643a916129926a6 /src
parent6d848dcd3bf513076bb2f5cadb138898422d4b30 (diff)
Do not display dupisate types
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/ContactDetails/ContactDetailsProperty.vue21
-rw-r--r--src/components/Properties/PropertyDateTime.vue6
-rw-r--r--src/components/Properties/PropertyMultipleText.vue6
-rw-r--r--src/components/Properties/PropertyText.vue6
4 files changed, 35 insertions, 4 deletions
diff --git a/src/components/ContactDetails/ContactDetailsProperty.vue b/src/components/ContactDetails/ContactDetailsProperty.vue
index 289efe3a..5c6d9509 100644
--- a/src/components/ContactDetails/ContactDetailsProperty.vue
+++ b/src/components/ContactDetails/ContactDetailsProperty.vue
@@ -26,7 +26,7 @@
:is="componentInstance" :select-type.sync="selectType" :prop-model="propModel"
:value.sync="value" :is-first-property="isFirstProperty" :property="property"
:is-last-property="isLastProperty" :class="{'property--last': isLastProperty}" :contact="contact"
- @delete="deleteProp" />
+ :options="sortedModelOptions" @delete="deleteProp" />
</template>
<script>
@@ -126,6 +126,25 @@ export default {
return this.properties[this.propName]
},
+ /**
+ * Remove duplicate name amongst options
+ * but make sure to include the selected one
+ * in the final list
+ *
+ * @returns {Array<Object>}
+ */
+ sortedModelOptions() {
+ if (this.propModel.options) {
+ return this.propModel.options.reduce((list, option) => {
+ if (!list.find(search => search.name === option.name)) {
+ list.push(option)
+ }
+ return list
+ }, this.selectType ? [this.selectType] : [])
+ }
+ return []
+ },
+
// select type handler
selectType: {
get() {
diff --git a/src/components/Properties/PropertyDateTime.vue b/src/components/Properties/PropertyDateTime.vue
index db312bcd..79064bf4 100644
--- a/src/components/Properties/PropertyDateTime.vue
+++ b/src/components/Properties/PropertyDateTime.vue
@@ -29,7 +29,7 @@
<div class="property__row">
<!-- type selector -->
<multiselect v-if="propModel.options" v-model="localType"
- :options="propModel.options" :searchable="false" :placeholder="t('contacts', 'Select type')"
+ :options="options" :searchable="false" :placeholder="t('contacts', 'Select type')"
class="multiselect-vue property__label" track-by="id" label="name"
@input="updateType" />
@@ -148,6 +148,10 @@ export default {
default: '',
required: true
},
+ options: {
+ type: Array,
+ default: () => []
+ },
property: {
type: Object,
default: () => {},
diff --git a/src/components/Properties/PropertyMultipleText.vue b/src/components/Properties/PropertyMultipleText.vue
index 6804c9e5..0196adf4 100644
--- a/src/components/Properties/PropertyMultipleText.vue
+++ b/src/components/Properties/PropertyMultipleText.vue
@@ -29,7 +29,7 @@
<div class="property__row">
<!-- type selector -->
<multiselect v-if="propModel.options" v-model="localType"
- :options="propModel.options" :searchable="false" :placeholder="t('contacts', 'Select type')"
+ :options="options" :searchable="false" :placeholder="t('contacts', 'Select type')"
class="multiselect-vue property__label" track-by="id" label="name"
@input="updateType" />
@@ -96,6 +96,10 @@ export default {
default: () => [],
required: true
},
+ options: {
+ type: Array,
+ default: () => []
+ },
property: {
type: Object,
default: () => {},
diff --git a/src/components/Properties/PropertyText.vue b/src/components/Properties/PropertyText.vue
index d5488bab..531e8e81 100644
--- a/src/components/Properties/PropertyText.vue
+++ b/src/components/Properties/PropertyText.vue
@@ -29,7 +29,7 @@
<div class="property__row">
<!-- type selector -->
<multiselect v-if="propModel.options" v-model="localType"
- :options="propModel.options" :searchable="false" :placeholder="t('contacts', 'Select type')"
+ :options="options" :searchable="false" :placeholder="t('contacts', 'Select type')"
class="multiselect-vue property__label" track-by="id" label="name"
@input="updateType" />
@@ -76,6 +76,10 @@ export default {
default: '',
required: true
},
+ options: {
+ type: Array,
+ default: () => []
+ },
isFirstProperty: {
type: Boolean,
default: true