feat: refs #8725 enable validations in formPopup

This commit is contained in:
Javier Segarra 2025-03-12 11:34:18 +01:00
parent 4f17691d86
commit 50e3385be4
3 changed files with 13 additions and 5 deletions

View File

@ -42,6 +42,7 @@ const onDataSaved = async (formData, requestResponse) => {
};
const onClick = async (saveAndContinue = showSaveAndContinueBtn) => {
await formModelRef.value.myForm.validate(true);
isSaveAndContinue.value = saveAndContinue;
if (formModelRef.value) {
await formModelRef.value.submitForm();
@ -66,13 +67,18 @@ defineExpose({
@on-data-saved="onDataSaved"
:prevent-submit="false"
>
<template #form="{ data, validate }">
<template #form="{ data, validate, validations }">
<span ref="closeButton" class="close-icon" v-close-popup>
<QIcon name="close" size="sm" />
</span>
<h1 class="title">{{ title }}</h1>
<p>{{ subtitle }}</p>
<slot name="form-inputs" :data="data" :validate="validate" />
<slot
name="form-inputs"
:data="data"
:validate="validate"
:validations="validations"
/>
<div class="q-mt-lg row justify-end">
<QBtn
:label="t('globals.cancel')"

View File

@ -1027,7 +1027,7 @@ const rowCtrlClickFunction = computed(() => {
:model="$attrs['data-key'] + 'Create'"
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
>
<template #form-inputs="{ data }">
<template #form-inputs="{ data, validations }">
<div :style="createComplement?.containerStyle">
<div
:style="createComplement?.previousStyle"
@ -1041,6 +1041,7 @@ const rowCtrlClickFunction = computed(() => {
:key="column.name"
:name="`column-create-${column.name}`"
:data="data"
:validations="validations"
:column-name="column.name"
:label="column.label"
>

View File

@ -708,7 +708,7 @@ onMounted(() => {
{{ footer?.amount }}
</span>
</template>
<template #column-create-itemFk="{ data }">
<template #column-create-itemFk="{ data, validations }">
<VnSelect
url="Items/search"
v-model="data.itemFk"
@ -722,7 +722,8 @@ onMounted(() => {
await setBuyUltimate(value, data);
}
"
:required="true"
required
:rules="[(val) => validations.required(true, val)]"
data-cy="itemFk-create-popup"
sort-by="nickname DESC"
>