Homepage, verejna cast, vetsi sada uprav a oprav
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<script setup>
|
||||
import {onMounted, reactive, ref, watch} from "vue";
|
||||
import FormWrapper from "components/FormWrapper.vue";
|
||||
import {setDefaultData} from "src/composables/form/formHandling";
|
||||
import ComboboxInput from "components/inputs/ComboboxInput.vue";
|
||||
import {commonProps} from "src/composables/inputs";
|
||||
|
||||
const props = defineProps({
|
||||
flight: {
|
||||
@@ -16,28 +16,27 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const formData = reactive({
|
||||
copilot: null,
|
||||
copilots: [],
|
||||
})
|
||||
|
||||
const solo = ref(true);
|
||||
const solo = ref(false);
|
||||
watch(() => solo.value, (newVal) => {
|
||||
if (!newVal) {
|
||||
formData.copilot = null;
|
||||
formData.copilots = [];
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (props.flight) {
|
||||
setDefaultData(formData, props.flight);
|
||||
solo.value = !formData.copilot;
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => props.flight, (newVal) => {
|
||||
if (newVal) {
|
||||
formData.copilots = newVal.copilots.map(copilot => ({id: copilot.id, name: copilot.name}));
|
||||
solo.value = formData.copilots.length === 0;
|
||||
}
|
||||
}, {deep: true, immediate: true});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FormWrapper v-model="formData">
|
||||
|
||||
<q-btn-toggle
|
||||
spread
|
||||
no-caps
|
||||
@@ -48,14 +47,13 @@ onMounted(() => {
|
||||
|
||||
<div v-if="!solo">
|
||||
<ComboboxInput
|
||||
class="q-my-lg"
|
||||
outlined
|
||||
standout
|
||||
v-for="i in flight.aircraft.seats - 1"
|
||||
:key="i"
|
||||
v-bind="commonProps"
|
||||
:options="copilots"
|
||||
v-model="formData.copilot"
|
||||
:key="formData.copilot"
|
||||
v-model="formData.copilots[i-1]"
|
||||
:clearable="true"
|
||||
label="Druhy pilot"
|
||||
:label="i === 1 ? 'Kopilot' : 'Pasažér'"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user