salix-front/src/components/CreateNewProvinceForm.vue

69 lines
1.9 KiB
Vue
Raw Normal View History

2023-12-20 15:23:42 +00:00
<script setup>
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
2024-04-23 11:03:32 +00:00
import VnSelect from 'src/components/common/VnSelect.vue';
2023-12-20 15:23:42 +00:00
import VnInput from 'src/components/common/VnInput.vue';
import FormModelPopup from './FormModelPopup.vue';
2023-12-20 15:23:42 +00:00
const emit = defineEmits(['onDataSaved']);
const { t } = useI18n();
const provinceFormData = reactive({
name: null,
autonomyFk: null,
});
const autonomiesOptions = ref([]);
2024-01-12 12:49:34 +00:00
const onDataSaved = (dataSaved) => {
emit('onDataSaved', dataSaved);
2023-12-20 15:23:42 +00:00
};
</script>
<template>
<FetchData
@on-fetch="(data) => (autonomiesOptions = data)"
auto-load
url="Autonomies"
/>
<FormModelPopup
:title="t('New province')"
:subtitle="t('Please, ensure you put the correct data!')"
2023-12-20 15:23:42 +00:00
url-create="provinces"
model="province"
:form-initial-data="provinceFormData"
@on-data-saved="onDataSaved($event)"
2023-12-20 15:23:42 +00:00
>
<template #form-inputs="{ data, validate }">
2023-12-20 15:23:42 +00:00
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
:label="t('Name')"
v-model="data.name"
:rules="validate('province.name')"
/>
2024-04-26 07:47:44 +00:00
<VnSelect
:label="t('Autonomy')"
:options="autonomiesOptions"
hide-selected
option-label="name"
option-value="id"
v-model="data.autonomyFk"
:rules="validate('province.autonomyFk')"
/>
2023-12-20 15:23:42 +00:00
</VnRow>
</template>
</FormModelPopup>
2023-12-20 15:23:42 +00:00
</template>
<i18n>
es:
New province: Nueva provincia
2023-12-20 15:23:42 +00:00
Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos!
Name: Nombre
Autonomy: Autonomía
</i18n>