2023-10-04 19:38:50 -04:00
|
|
|
<script setup lang="ts">
|
2023-12-29 20:11:07 -05:00
|
|
|
import { Field, ErrorMessage } from "vee-validate";
|
2023-10-04 19:38:50 -04:00
|
|
|
import { NamePath } from "ant-design-vue/es/form/interface";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { FormChapter } from "@client/types/form/story";
|
2023-10-04 19:38:50 -04:00
|
|
|
|
2023-12-29 20:11:07 -05:00
|
|
|
import { bare } from "@client/editorConfig";
|
2023-10-04 19:38:50 -04:00
|
|
|
import elBands from "../atoms/bands.vue";
|
|
|
|
import genre from "../atoms/genre.vue";
|
|
|
|
import elCharacters from "../atoms/characters.vue";
|
|
|
|
import elPairings from "../atoms/pairings.vue";
|
|
|
|
import uploadOrPaste from "./uploadOrPaste.vue";
|
2024-03-16 21:18:07 -04:00
|
|
|
import { IBand } from "@models/band";
|
2023-10-04 19:38:50 -04:00
|
|
|
// import test1 from
|
|
|
|
|
|
|
|
let { name, data } = defineProps<{
|
|
|
|
name: NamePath;
|
|
|
|
data: FormChapter;
|
|
|
|
}>();
|
|
|
|
let acData = toRef(data);
|
2024-03-16 21:18:07 -04:00
|
|
|
let { data: _bands } = await useApiFetch<IBand[]>("/band/all");
|
2023-10-04 19:38:50 -04:00
|
|
|
let bands = ref(_bands);
|
|
|
|
provide("curName", name + ".");
|
|
|
|
provide("bandlist", bands);
|
|
|
|
const selectedBands = ref(data.bands || []);
|
|
|
|
const updateBands = (val) => {
|
|
|
|
selectedBands.value = val;
|
|
|
|
// data.value.bands = val;
|
|
|
|
};
|
|
|
|
provide("selectedBands", {
|
|
|
|
sb: selectedBands,
|
|
|
|
updateBands,
|
|
|
|
});
|
|
|
|
const wrapc = { span: 12 };
|
2024-03-16 21:18:07 -04:00
|
|
|
const tbase = `storyform.${name}.form`;
|
2023-10-04 19:38:50 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
2024-03-16 21:18:07 -04:00
|
|
|
<div :data-testid="tbase">
|
2023-10-04 19:38:50 -04:00
|
|
|
<a-row :gutter="[10, 0]">
|
|
|
|
<a-col :span="12">
|
2023-12-29 20:11:07 -05:00
|
|
|
<Field :name="name + '.chapterTitle'" v-slot="{ value, field, errorMessage }">
|
|
|
|
<a-form-item :name="[field.name as string]" label="Chapter title" :help="errorMessage" :status="!!errorMessage ? 'error' : undefined">
|
2024-03-16 21:18:07 -04:00
|
|
|
<a-input :data-testid="`${tbase}.title`" v-bind="field" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-form-item>
|
|
|
|
</Field>
|
|
|
|
</a-col>
|
|
|
|
<a-col :span="12">
|
2024-03-16 21:18:07 -04:00
|
|
|
<el-bands :data-testid="`${tbase}.bands`" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
<a-row :gutter="[10, 0]">
|
|
|
|
<a-col :span="12">
|
2024-03-16 21:18:07 -04:00
|
|
|
<base-editor :data-testid="`${tbase}.summary`" v-model:val="acData.summary" :name="name + '.summary'" :wrap-col="wrapc" label="Summary" :init="bare" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-col>
|
|
|
|
<a-col :span="12">
|
2024-03-16 21:18:07 -04:00
|
|
|
<base-editor :data-testid="`${tbase}.notes`" v-model:val="acData.notes" :name="name + '.notes'" :wrap-col="wrapc" label="Author's notes" :init="bare" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
<a-row :gutter="[10, 0]">
|
|
|
|
<a-col :span="12">
|
2024-03-16 21:18:07 -04:00
|
|
|
<el-characters :data-testid="`${tbase}.characters`" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-col>
|
|
|
|
<a-col :span="12">
|
2024-03-16 21:18:07 -04:00
|
|
|
<el-pairings :data-testid="`${tbase}.relationships`" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-col>
|
|
|
|
</a-row>
|
2023-12-29 20:11:07 -05:00
|
|
|
<Field :name="name + '.nsfw'" type="checkbox" :unchecked-value="false" :value="true" v-slot="{ value, field, errorMessage }">
|
2024-03-16 21:18:07 -04:00
|
|
|
<a-checkbox :data-testid="`${tbase}.nsfw`" v-bind="field" v-model="field.value"> Has NSFW content </a-checkbox>
|
2023-10-04 19:38:50 -04:00
|
|
|
<error-message :name="field.name" />
|
|
|
|
</Field>
|
2023-12-29 20:11:07 -05:00
|
|
|
<Field :name="name + '.loggedInOnly'" type="checkbox" :unchecked-value="false" :value="true" v-slot="{ value, field, errorMessage }">
|
2024-03-16 21:18:07 -04:00
|
|
|
<a-checkbox :data-testid="`${tbase}.loggedInOnly`" v-bind="field"> Visible only to registered users </a-checkbox>
|
2023-10-04 19:38:50 -04:00
|
|
|
<error-message :name="field.name" />
|
|
|
|
</Field>
|
2023-12-29 20:11:07 -05:00
|
|
|
<Field :name="name + '.hidden'" type="checkbox" :unchecked-value="false" :value="true" v-slot="{ value, field, errorMessage }">
|
2023-10-04 19:38:50 -04:00
|
|
|
<a-tooltip>
|
2023-12-29 20:11:07 -05:00
|
|
|
<template #title> Hides your story from everyone except you and site admins. </template>
|
2024-03-16 21:18:07 -04:00
|
|
|
<a-checkbox v-bind="field" :data-testid="`${tbase}.hidden`"> Hidden </a-checkbox>
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-tooltip>
|
|
|
|
</Field>
|
|
|
|
<a-row>
|
|
|
|
<a-col :span="24">
|
2024-03-16 21:18:07 -04:00
|
|
|
<genre :data-testid="`${tbase}.genre`" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
<a-divider> Contents </a-divider>
|
2024-03-16 21:18:07 -04:00
|
|
|
<upload-or-paste :data-testid="`${tbase}.uploadOrPaste`" />
|
|
|
|
<Field :hidden="true" :name="name + '.id'" v-if="!!data.id" :model-value="data.id" />
|
2023-10-04 19:38:50 -04:00
|
|
|
</div>
|
|
|
|
</template>
|