sort InputCombo dropdown option by label

This commit is contained in:
j3d1 2019-12-29 12:43:17 +01:00
parent d9b598d078
commit 58ee59ddbc

View file

@ -10,8 +10,8 @@
>Search</button>
<div class="dropdown-menu">
<a
v-for="option in options"
:key="option[uniqueKey]"
v-for="(option, index) in sortedOptions"
:key="index"
class="dropdown-item"
@click="setInternalValue(option)"
:class="{ active: option == selectedOption }"
@ -49,7 +49,8 @@ export default {
addingOption: false
}),
computed: {
isValid: ({options, nameKey, internalName}) => options.some(e => e[nameKey] == internalName)
isValid: ({options, nameKey, internalName}) => options.some(e => e[nameKey] == internalName),
sortedOptions: ({options, nameKey}) => options.sort((a, b) => a[nameKey] > b[nameKey]),
},
watch: {
internalName(newValue, oldValue) {