highlight selected element in InputCombo ad fix minor bug
This commit is contained in:
parent
14d2c05c1f
commit
2f653382eb
1 changed files with 5 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
||||||
:key="option[uniqueKey]"
|
:key="option[uniqueKey]"
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
@click="setInternalValue(option)"
|
@click="setInternalValue(option)"
|
||||||
|
:class="{ active: option == selectedOption }"
|
||||||
>
|
>
|
||||||
{{ option[nameKey] }}
|
{{ option[nameKey] }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -44,17 +45,17 @@ export default {
|
||||||
props: [ 'label', 'model', 'nameKey', 'uniqueKey', 'options', 'onOptionAdd' ],
|
props: [ 'label', 'model', 'nameKey', 'uniqueKey', 'options', 'onOptionAdd' ],
|
||||||
data: ({ options, model, nameKey, uniqueKey }) => ({
|
data: ({ options, model, nameKey, uniqueKey }) => ({
|
||||||
internalName: model[nameKey],
|
internalName: model[nameKey],
|
||||||
selectedOption: options.filter(e => e[uniqueKey] === model[uniqueKey])[0],
|
selectedOption: options.filter(e => e[uniqueKey] == model[uniqueKey])[0],
|
||||||
addingOption: false
|
addingOption: false
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
isValid: ({options, nameKey, internalName}) => options.some(e => e[nameKey] === internalName)
|
isValid: ({options, nameKey, internalName}) => options.some(e => e[nameKey] == internalName)
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
internalName(newValue, oldValue) {
|
internalName(newValue, oldValue) {
|
||||||
if (this.isValid) {
|
if (this.isValid) {
|
||||||
if(newValue!=this.selectedOption[this.nameKey]){
|
if(!this.selectedOption || newValue!=this.selectedOption[this.nameKey]){
|
||||||
this.selectedOption = this.options.filter(e => e[this.nameKey] === this.internalName)[0];
|
this.selectedOption = this.options.filter(e => e[this.nameKey] === newValue)[0];
|
||||||
}
|
}
|
||||||
this.model[this.nameKey] = this.selectedOption[this.nameKey];
|
this.model[this.nameKey] = this.selectedOption[this.nameKey];
|
||||||
this.model[this.uniqueKey] = this.selectedOption[this.uniqueKey];
|
this.model[this.uniqueKey] = this.selectedOption[this.uniqueKey];
|
||||||
|
|
Loading…
Reference in a new issue