removeMissingItem disabled

This commit is contained in:
Chris Scoggins 2022-01-26 16:45:13 -06:00
parent ec2cbc9b1b
commit 598f53f3d4
No known key found for this signature in database
GPG Key ID: 41617A4206CCBAC6

View File

@ -8,8 +8,9 @@
@change="new_value = $event.val"
@remove="new_value = undefined"
:initial_selection="initialSelection"
:initial_single_selection="initialSingleSelection"
:model="model"
:multiple="useMultiple"
:multiple="useMultiple || false"
:sticky_options="sticky_options"
:allow_create="form.allow_create"
:create_placeholder="createPlaceholder"
@ -76,25 +77,21 @@ export default {
return this.form?.multiple || this.form?.ordered || false
},
initialSelection() {
if (!this.new_value) {
return
}
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.new_value || !this.useMultiple) {
return undefined
}
if (this.form?.ordered && this.first_run) {
return this.flattenItems(arrayValues)
return this.flattenItems(this.new_value)
} else {
return arrayValues
return this.new_value
}
},
initialSingleSelection() {
if (this.useMultiple) {
return undefined
} else {
return this.new_value
}
},
createPlaceholder() {