|
Lines 1-45
Link Here
|
| 1 |
<template> |
|
|
| 2 |
<v-select |
| 3 |
label="name" |
| 4 |
:reduce="vendor => vendor.id" |
| 5 |
:options="vendorOptions" |
| 6 |
:filter-by="filterVendors" |
| 7 |
> |
| 8 |
<template v-slot:option="v"> |
| 9 |
{{ v.name }} |
| 10 |
<br /> |
| 11 |
<cite>{{ v.aliases.map(a => a.alias).join(", ") }}</cite> |
| 12 |
</template> |
| 13 |
</v-select> |
| 14 |
</template> |
| 15 |
|
| 16 |
<script> |
| 17 |
import { computed, inject } from "vue"; |
| 18 |
import { storeToRefs } from "pinia"; |
| 19 |
export default { |
| 20 |
setup() { |
| 21 |
const vendorStore = inject("vendorStore"); |
| 22 |
const { vendors } = storeToRefs(vendorStore); |
| 23 |
|
| 24 |
const filterVendors = (vendor, label, search) => { |
| 25 |
return ( |
| 26 |
(vendor.full_search || "") |
| 27 |
.toLocaleLowerCase() |
| 28 |
.indexOf(search.toLocaleLowerCase()) > -1 |
| 29 |
); |
| 30 |
}; |
| 31 |
|
| 32 |
const vendorOptions = computed(() => { |
| 33 |
return vendors.value.map(v => ({ |
| 34 |
...v, |
| 35 |
full_search: |
| 36 |
v.name + |
| 37 |
(v.aliases.length > 0 |
| 38 |
? " (" + v.aliases.map(a => a.alias).join(", ") + ")" |
| 39 |
: ""), |
| 40 |
})); |
| 41 |
}); |
| 42 |
return { vendors, vendorOptions, filterVendors }; |
| 43 |
}, |
| 44 |
}; |
| 45 |
</script> |