removeMissingItem disabled

This commit is contained in:
Chris Scoggins
2022-01-26 16:45:13 -06:00
parent ec2cbc9b1b
commit 598f53f3d4

View File

@@ -8,8 +8,9 @@
@change="new_value = $event.val" @change="new_value = $event.val"
@remove="new_value = undefined" @remove="new_value = undefined"
:initial_selection="initialSelection" :initial_selection="initialSelection"
:initial_single_selection="initialSingleSelection"
:model="model" :model="model"
:multiple="useMultiple" :multiple="useMultiple || false"
:sticky_options="sticky_options" :sticky_options="sticky_options"
:allow_create="form.allow_create" :allow_create="form.allow_create"
:create_placeholder="createPlaceholder" :create_placeholder="createPlaceholder"
@@ -76,25 +77,21 @@ export default {
return this.form?.multiple || this.form?.ordered || false return this.form?.multiple || this.form?.ordered || false
}, },
initialSelection() { initialSelection() {
if (!this.new_value) { if (!this.new_value || !this.useMultiple) {
return return undefined
}
let this_value = this.new_value
let arrayValues = undefined
// multiselect is expect to get an array of objects - make sure it gets one
if (Array.isArray(this_value)) {
arrayValues = this_value
} else if (!this_value) {
arrayValues = []
} else if (typeof this_value === "object") {
arrayValues = [this_value]
} else {
arrayValues = [{ id: -1, name: this_value }]
} }
if (this.form?.ordered && this.first_run) { if (this.form?.ordered && this.first_run) {
return this.flattenItems(arrayValues) return this.flattenItems(this.new_value)
} else { } else {
return arrayValues return this.new_value
}
},
initialSingleSelection() {
if (this.useMultiple) {
return undefined
} else {
return this.new_value
} }
}, },
createPlaceholder() { createPlaceholder() {