2023-10-04 19:38:50 -04:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { Field, useFieldArray } from "vee-validate";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { IBand } from "@models/band";
|
2023-10-04 19:38:50 -04:00
|
|
|
|
|
|
|
const { sb: selectedBands } = inject<any>("selectedBands");
|
|
|
|
const allBands = inject<Ref<IBand[]>>("bandlist");
|
|
|
|
const fname = inject<string>("curName");
|
|
|
|
const opts = computed(() => {
|
|
|
|
const uf: any[] = [];
|
|
|
|
selectedBands.value.forEach((v: number) => {
|
|
|
|
uf.push(allBands?.value.find((a) => a._id == v)?.characters);
|
|
|
|
});
|
|
|
|
return uf.flat(Infinity).map((a) => ({ value: a, label: a }));
|
|
|
|
});
|
2023-12-29 20:53:29 -05:00
|
|
|
const { fields, push, remove, replace, update } = useFieldArray<string[]>(fname + "relationships");
|
2023-10-04 19:38:50 -04:00
|
|
|
// replace([]);
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<a-form-item label="Pairings">
|
2023-12-29 20:53:29 -05:00
|
|
|
<a-row :gutter="5" :wrap="true" v-for="(field, idx) in fields" :key="field.key">
|
2023-10-04 19:38:50 -04:00
|
|
|
<Field :name="fname + 'relationships' + `[${idx}]`">
|
2023-12-29 20:53:29 -05:00
|
|
|
<a-select mode="multiple" :options="opts" v-model:value="field.value as string[]" @change="(val) => update(idx, val as string[])">
|
2023-10-04 19:38:50 -04:00
|
|
|
<template #removeIcon>
|
|
|
|
<i class="far fa-circle-x" />
|
|
|
|
</template>
|
|
|
|
</a-select>
|
|
|
|
</Field>
|
|
|
|
<a-col :span="4">
|
|
|
|
<a-button @click="(e) => remove(idx)"> - </a-button>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
<a-row justify="end">
|
|
|
|
<a-col :span="2">
|
|
|
|
<a-button @click="(e) => push([])"> + </a-button>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-form-item>
|
|
|
|
</template>
|