Label select component Fixed label colors

This commit is contained in:
Jérémy Munsch 2022-08-31 12:44:18 +02:00
parent 3045a809b3
commit 6f9cec1b2d
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -7,12 +7,12 @@
label="label"
:options="labels"
>
<template #option="{ option }: { option: SelectModel }">
<template #option="{ label, color }: { label: string, color: string }">
<span
class="py-1 px-2"
:style="`background-color: ${(option as SelectModel).color};color: ${invertColor((option as SelectModel).color, true)};`"
:style="`background-color: ${color};color: ${invertColor(color, true)};`"
>
{{ String(option.label) }}
{{ String(label) }}
</span>
</template>
<template #no-options>
@ -44,14 +44,14 @@ export default defineComponent({
const json = String(this.$attrs.json ?? "{}"),
data = JSON.parse(json);
this.name = data.name;
for (let label of data.value ?? []) {
for (const label of data.value ?? []) {
this.selectedLabels.push({
label: label.name,
value: label.id,
color: label.color,
});
}
for (let label of data.labels) {
for (const label of data.labels) {
this.labels.push({
label: label.name,
value: label.id,