diff --git a/client/web/compose/src/components/ModuleFields/Editor/Record.vue b/client/web/compose/src/components/ModuleFields/Editor/Record.vue
index 6f3f53386..9f4617425 100644
--- a/client/web/compose/src/components/ModuleFields/Editor/Record.vue
+++ b/client/web/compose/src/components/ModuleFields/Editor/Record.vue
@@ -340,15 +340,15 @@ export default {
}
},
- isSelectable (recordID) {
+ isSelectable ({ recordID } = {}) {
if (!recordID) {
return false
}
- if (this.field.isMulti && !this.field.options.isUniqueMultiValue) {
- return this.value !== recordID
+ if (this.field.isMulti) {
+ return !this.field.options.isUniqueMultiValue || !this.value.includes(recordID)
} else {
- return !(this.value || []).includes(recordID)
+ return this.value !== recordID
}
},
diff --git a/client/web/compose/src/components/ModuleFields/Editor/Select.vue b/client/web/compose/src/components/ModuleFields/Editor/Select.vue
index b873fc6da..0cd5df0f3 100644
--- a/client/web/compose/src/components/ModuleFields/Editor/Select.vue
+++ b/client/web/compose/src/components/ModuleFields/Editor/Select.vue
@@ -56,6 +56,7 @@
:options="selectOptions"
:placeholder="$t('kind.select.placeholder')"
:reduce="o => o.value"
+ :selectable="isSelectable"
label="text"
@input="selectChange"
/>
@@ -64,8 +65,10 @@
v-if="field.options.selectType === 'multiple'"
v-model="value"
:options="selectOptions"
- label="text"
+ :placeholder="$t('kind.select.placeholder')"
:reduce="o => o.value"
+ :selectable="isSelectable"
+ label="text"
multiple
/>
@@ -77,6 +80,7 @@
:options="selectOptions"
:reduce="o => o.value"
:placeholder="$t('kind.select.placeholder')"
+ :selectable="isSelectable"
label="text"
/>
@@ -91,10 +95,11 @@
{
- const disabled = o.value && this.field.isMulti && !this.field.options.isUniqueMultiValue
- ? this.value === o.value
- : (this.value || []).includes(o.value)
- return { ...o, disabled: this.field.options.selectType !== 'list' && disabled }
- }).filter(({ value = '', text = '' }) => value && text)
+ return this.field.options.options.filter(({ value = '', text = '' }) => value && text)
},
},
@@ -144,6 +144,16 @@ export default {
findLabel (v) {
return (this.selectOptions.find(({ value }) => value === v) || {}).text || v
},
+
+ isSelectable ({ value } = {}) {
+ if (this.field.options.selectType === 'list') return true
+
+ if (this.field.isMulti) {
+ return !this.field.options.isUniqueMultiValue || !(this.value || []).includes(value)
+ } else {
+ return this.value !== value
+ }
+ },
},
}
diff --git a/client/web/compose/src/components/ModuleFields/Editor/User.vue b/client/web/compose/src/components/ModuleFields/Editor/User.vue
index 61b0b752f..82f5e3814 100644
--- a/client/web/compose/src/components/ModuleFields/Editor/User.vue
+++ b/client/web/compose/src/components/ModuleFields/Editor/User.vue
@@ -48,7 +48,7 @@
:get-option-label="getOptionLabel"
:get-option-key="getOptionKey"
:filterable="false"
- :selectable="option => option.selectable"
+ :selectable="isSelectable"
:loading="processing"
@search="search"
@input="updateValue($event)"
@@ -71,7 +71,7 @@
:get-option-label="getOptionLabel"
:get-option-key="getOptionKey"
:filterable="false"
- :selectable="option => option.selectable"
+ :selectable="isSelectable"
:loading="processing"
multiple
@search="search"
@@ -96,7 +96,7 @@
:get-option-key="getOptionKey"
:value="getUserIDByIndex(ctx.index)"
:filterable="false"
- :selectable="option => option.selectable"
+ :selectable="isSelectable"
:loading="processing"
@search="search"
@input="updateValue($event, ctx.index)"
@@ -123,7 +123,7 @@
:value="getUserIDByIndex()"
:clearable="field.name !== 'ownedBy'"
:filterable="false"
- :selectable="option => option.selectable"
+ :selectable="isSelectable"
:loading="processing"
@input="updateValue($event)"
@search="search"
@@ -184,14 +184,7 @@ export default {
}),
options () {
- return this.users.map(u => {
- return {
- ...u,
- selectable: this.field.isMulti && !this.field.options.isUniqueMultiValue
- ? this.value !== u.userID
- : !(this.value || []).includes(u.userID),
- }
- })
+ return this.users
},
// This is used in the case of using the multiple select option
@@ -284,6 +277,18 @@ export default {
return name || username || email || `<@${userID}>`
},
+ isSelectable ({ userID } = {}) {
+ if (!userID) {
+ return false
+ }
+
+ if (this.field.isMulti) {
+ return !this.field.options.isUniqueMultiValue || !this.value.includes(userID)
+ } else {
+ return this.value !== userID
+ }
+ },
+
/**
* Updates record value with user
*
diff --git a/lib/vue/src/components/input/CInputSelect.vue b/lib/vue/src/components/input/CInputSelect.vue
index cfecf1a35..270f5729f 100644
--- a/lib/vue/src/components/input/CInputSelect.vue
+++ b/lib/vue/src/components/input/CInputSelect.vue
@@ -7,8 +7,9 @@
:options="options"
:searchable="searchable"
:disabled="disabled"
+ :selectable="selectable"
:calculate-position="calculateDropdownPosition"
- :append-to-body="appendToBody"
+ :append-to-body="appendToBody"
class="bg-white rounded"
:class="sizeClass"
@search="onSearch"
@@ -79,6 +80,11 @@ export default {
type: Boolean,
default: false,
},
+
+ selectable: {
+ type: Function,
+ default: o => !o.disabled,
+ },
},
computed: {