2023-10-04 19:38:50 -04:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { RuleExpression, useField } from "vee-validate";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { cs } from "@client/storyFormSchema";
|
|
|
|
import { IBand } from "@models/band";
|
2023-10-04 19:38:50 -04:00
|
|
|
const fname = inject<string>("curName");
|
|
|
|
const { sb: selectedBands } = inject<any>("selectedBands");
|
|
|
|
const allBands = inject<Ref<IBand[]>>("bandlist");
|
|
|
|
const opts = computed(() => {
|
|
|
|
const unflattened: any[] = [];
|
|
|
|
selectedBands?.value?.forEach((v: number) => {
|
|
|
|
unflattened.push(allBands?.value.find((a) => a._id == v)?.characters);
|
|
|
|
});
|
|
|
|
return unflattened.flat(Infinity).map((a) => ({ value: a, label: a }));
|
|
|
|
});
|
2023-12-29 20:53:29 -05:00
|
|
|
const charField = useField<string[]>(fname + "characters", cs.fields.characters as unknown as MaybeRef<RuleExpression<string[]>>);
|
2023-10-04 19:38:50 -04:00
|
|
|
const { value, errorMessage, name: bandName, setValue } = charField;
|
|
|
|
// setValue([]);
|
|
|
|
</script>
|
|
|
|
<template>
|
2023-12-29 20:53:29 -05:00
|
|
|
<a-form-item :help="errorMessage" label="Characters" :name="bandName as string" :validate-status="!!errorMessage ? 'error' : undefined">
|
2024-03-16 21:18:07 -04:00
|
|
|
<a-select v-bind="$attrs" mode="multiple" :options="opts" v-model:value="value">
|
2023-10-04 19:38:50 -04:00
|
|
|
<template #removeIcon>
|
|
|
|
<i class="far fa-circle-x" />
|
|
|
|
</template>
|
|
|
|
</a-select>
|
|
|
|
</a-form-item>
|
|
|
|
</template>
|