refactor: refs #8372 update FormModelPopup to use props for save and continue logic

This commit is contained in:
Jorge Penadés 2025-02-24 11:03:14 +01:00
parent 30532c9eab
commit 09b613cac1
2 changed files with 7 additions and 14 deletions

View File

@ -6,7 +6,7 @@ import FormModel from 'components/FormModel.vue';
const emit = defineEmits(['onDataSaved', 'onDataCanceled']); const emit = defineEmits(['onDataSaved', 'onDataCanceled']);
defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
default: '', default: '',
@ -25,10 +25,14 @@ const { t } = useI18n();
const formModelRef = ref(null); const formModelRef = ref(null);
const closeButton = ref(null); const closeButton = ref(null);
const isSaveAndContinue = ref(false); const isSaveAndContinue = ref(props.showSaveAndContinueBtn);
const isLoading = computed(() => formModelRef.value?.isLoading);
const reset = computed(() => formModelRef.value?.reset);
const onDataSaved = (formData, requestResponse) => { const onDataSaved = (formData, requestResponse) => {
if (closeButton.value && !isSaveAndContinue.value) closeButton.value.click(); if (!isSaveAndContinue.value) closeButton.value?.click();
emit('onDataSaved', formData, requestResponse); emit('onDataSaved', formData, requestResponse);
isSaveAndContinue.value = props.showSaveAndContinueBtn;
}; };
const onClick = async (saveAndContinue) => { const onClick = async (saveAndContinue) => {
@ -36,9 +40,6 @@ const onClick = async (saveAndContinue) => {
await formModelRef.value.save(); await formModelRef.value.save();
}; };
const isLoading = computed(() => formModelRef.value?.isLoading);
const reset = computed(() => formModelRef.value?.reset);
defineExpose({ defineExpose({
isLoading, isLoading,
onDataSaved, onDataSaved,

View File

@ -961,14 +961,6 @@ function cardClick(_, row) {
transition-show="scale" transition-show="scale"
transition-hide="scale" transition-hide="scale"
:full-width="createComplement?.isFullWidth ?? false" :full-width="createComplement?.isFullWidth ?? false"
@before-hide="
() => {
if (createRef.isSaveAndContinue) {
showForm = true;
createForm.formInitialData = { ...create.formInitialData };
}
}
"
data-cy="vn-table-create-dialog" data-cy="vn-table-create-dialog"
> >
<FormModelPopup <FormModelPopup