dev: hotfix, added combobox objectsToItems
This commit is contained in:
@@ -20,4 +20,17 @@ export function recStrToItem(input: Record<string, string>): Item[] {
|
||||
return items
|
||||
}
|
||||
|
||||
export function objectsToItems(input: object[], key = 'id', label = 'name'): Item[] {
|
||||
const items: Item[] = []
|
||||
for (const item of input) {
|
||||
if (item.hasOwnProperty(key) && item.hasOwnProperty(label)) {
|
||||
items.push({
|
||||
value: item[key as keyof typeof item], // the hasOwnProperty check should be enough
|
||||
label: item[label as keyof typeof item], // the hasOwnProperty check should be enough
|
||||
})
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
export { default as Combobox } from './combobox.vue'
|
||||
|
||||
Reference in New Issue
Block a user