74 lines
1.7 KiB
Vue
74 lines
1.7 KiB
Vue
<template>
|
|
<div>
|
|
<VueSelect
|
|
v-model="selectedLabels"
|
|
:multiple="true"
|
|
:clearable="true"
|
|
label="label"
|
|
:options="labels"
|
|
>
|
|
<template #option="{ option }: { option: SelectModel }">
|
|
<span
|
|
class="py-1 px-2"
|
|
:style="`background-color: ${(option as SelectModel).color};color: ${invertColor((option as SelectModel).color, true)};`"
|
|
>
|
|
{{ String(option.label) }}
|
|
</span>
|
|
</template>
|
|
<template #no-options>
|
|
{{ __("Pus de label disponibles") }}
|
|
</template>
|
|
</VueSelect>
|
|
<input
|
|
v-for="label of selectedLabels"
|
|
type="hidden"
|
|
:key="label.value"
|
|
:value="label.value"
|
|
:name="`${name}[]`"
|
|
>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent } from "vue";
|
|
import VueSelect from "vue-select";
|
|
import trans from "../modules/trans";
|
|
import colors from "../modules/colors";
|
|
|
|
export default defineComponent({
|
|
mixins: [trans, colors],
|
|
components: {
|
|
VueSelect,
|
|
},
|
|
mounted() {
|
|
const json = String(this.$attrs.json ?? "{}"),
|
|
data = JSON.parse(json);
|
|
this.name = data.name;
|
|
for (let label of data.value ?? []) {
|
|
this.selectedLabels.push({
|
|
label: label.name,
|
|
value: label.id,
|
|
color: label.color,
|
|
});
|
|
}
|
|
for (let label of data.labels) {
|
|
this.labels.push({
|
|
label: label.name,
|
|
value: label.id,
|
|
color: label.color,
|
|
});
|
|
}
|
|
},
|
|
data(): {
|
|
name: string;
|
|
selectedLabels: SelectModel[];
|
|
labels: SelectModel[];
|
|
} {
|
|
return {
|
|
name: "",
|
|
selectedLabels: [],
|
|
labels: [],
|
|
};
|
|
},
|
|
});
|
|
</script>
|