69 lines
1.9 KiB
Vue
69 lines
1.9 KiB
Vue
<script setup>
|
|
import {reactive, watch} from "vue";
|
|
import FormWrapper from "components/FormWrapper.vue";
|
|
import {setDefaultData} from "src/composables/form/formHandling";
|
|
import RichTextEditor from "components/inputs/RichTextEditor.vue";
|
|
import {commonProps} from "src/composables/inputs";
|
|
import ComboboxInput from "components/inputs/ComboboxInput.vue";
|
|
import SlugInput from "components/inputs/SlugInput.vue";
|
|
import {storeToRefs} from "pinia";
|
|
import {useLoggedUserStore} from "stores/LoggedUser";
|
|
|
|
const props = defineProps({
|
|
flight: {
|
|
type: Object,
|
|
required: false
|
|
},
|
|
events: {
|
|
type: Array,
|
|
required: false,
|
|
},
|
|
isRequestPending: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false,
|
|
}
|
|
});
|
|
|
|
const formData = reactive({
|
|
name: "",
|
|
event: null,
|
|
description: "",
|
|
urlSlug: "",
|
|
isPublic: null
|
|
})
|
|
|
|
|
|
const loggedUser = storeToRefs(useLoggedUserStore()).user;
|
|
|
|
watch(() => props.flight, (newVal) => {
|
|
if (newVal) {
|
|
setDefaultData(formData, newVal);
|
|
|
|
if (newVal.event) {
|
|
formData.event = {id: newVal.event.id, name: newVal.event.name};
|
|
}
|
|
}
|
|
}, {immediate: true});
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<FormWrapper v-model="formData" :is-request-pending="props.isRequestPending">
|
|
<ComboboxInput :options="events" v-if="events" v-model="formData.event" label="Událost" v-bind="commonProps"/>
|
|
<q-input type="text" v-model="formData.name" label="Jméno letu" v-bind="commonProps" />
|
|
<template v-if="loggedUser?.publicUsername">
|
|
<SlugInput
|
|
v-if="formData.isPublic"
|
|
v-bind="commonProps"
|
|
v-model="formData.urlSlug"
|
|
label="URL"
|
|
:url="`/${loggedUser.publicUsername}/`"
|
|
:slug-source="formData.name"
|
|
/>
|
|
<q-checkbox v-model="formData.isPublic" label="Veřejný?"/>
|
|
</template>
|
|
<RichTextEditor v-model="formData.description" v-bind="commonProps" label="Popis letu, poznámky, ..."/>
|
|
</FormWrapper>
|
|
</template>
|