2022-08-30 13:21:07 +00:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<VueSelect
|
|
|
|
|
v-model="selectedLabels"
|
|
|
|
|
:multiple="true"
|
|
|
|
|
:clearable="true"
|
|
|
|
|
label="label"
|
|
|
|
|
:options="labels"
|
|
|
|
|
>
|
2022-08-31 12:44:18 +02:00
|
|
|
<template #option="{ label, color }: { label: string, color: string }">
|
2022-08-30 13:21:07 +00:00
|
|
|
<span
|
|
|
|
|
class="py-1 px-2"
|
2022-08-31 12:44:18 +02:00
|
|
|
:style="`background-color: ${color};color: ${invertColor(color, true)};`"
|
2022-08-30 13:21:07 +00:00
|
|
|
>
|
2022-08-31 12:44:18 +02:00
|
|
|
{{ String(label) }}
|
2022-08-30 13:21:07 +00:00
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template #no-options>
|
2023-08-14 09:23:39 +00:00
|
|
|
{{ __("Plus de label disponibles") }}
|
2022-08-30 13:21:07 +00:00
|
|
|
</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";
|
2023-08-14 09:23:39 +00:00
|
|
|
import colors from "../../modules/colors";
|
|
|
|
|
import trans from "../../modules/trans";
|
2022-08-30 13:21:07 +00:00
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
mixins: [trans, colors],
|
|
|
|
|
components: {
|
|
|
|
|
VueSelect,
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
const json = String(this.$attrs.json ?? "{}"),
|
|
|
|
|
data = JSON.parse(json);
|
|
|
|
|
this.name = data.name;
|
2022-08-31 12:44:18 +02:00
|
|
|
for (const label of data.value ?? []) {
|
2022-08-30 13:21:07 +00:00
|
|
|
this.selectedLabels.push({
|
|
|
|
|
label: label.name,
|
|
|
|
|
value: label.id,
|
|
|
|
|
color: label.color,
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-08-31 12:44:18 +02:00
|
|
|
for (const label of data.labels) {
|
2022-08-30 13:21:07 +00:00
|
|
|
this.labels.push({
|
|
|
|
|
label: label.name,
|
|
|
|
|
value: label.id,
|
|
|
|
|
color: label.color,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data(): {
|
|
|
|
|
name: string;
|
|
|
|
|
selectedLabels: SelectModel[];
|
|
|
|
|
labels: SelectModel[];
|
|
|
|
|
} {
|
|
|
|
|
return {
|
|
|
|
|
name: "",
|
|
|
|
|
selectedLabels: [],
|
|
|
|
|
labels: [],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2023-08-14 09:23:39 +00:00
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "vue-select/dist/vue-select.css";
|
|
|
|
|
</style>
|