From 09b613cac19ed233ecfeb3a2012f53bcc52488aa Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 24 Feb 2025 11:03:14 +0100 Subject: [PATCH] refactor: refs #8372 update FormModelPopup to use props for save and continue logic --- src/components/FormModelPopup.vue | 13 +++++++------ src/components/VnTable/VnTable.vue | 8 -------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/components/FormModelPopup.vue b/src/components/FormModelPopup.vue index 672eeff7a..db9974422 100644 --- a/src/components/FormModelPopup.vue +++ b/src/components/FormModelPopup.vue @@ -6,7 +6,7 @@ import FormModel from 'components/FormModel.vue'; const emit = defineEmits(['onDataSaved', 'onDataCanceled']); -defineProps({ +const props = defineProps({ title: { type: String, default: '', @@ -25,10 +25,14 @@ const { t } = useI18n(); const formModelRef = 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) => { - if (closeButton.value && !isSaveAndContinue.value) closeButton.value.click(); + if (!isSaveAndContinue.value) closeButton.value?.click(); emit('onDataSaved', formData, requestResponse); + isSaveAndContinue.value = props.showSaveAndContinueBtn; }; const onClick = async (saveAndContinue) => { @@ -36,9 +40,6 @@ const onClick = async (saveAndContinue) => { await formModelRef.value.save(); }; -const isLoading = computed(() => formModelRef.value?.isLoading); -const reset = computed(() => formModelRef.value?.reset); - defineExpose({ isLoading, onDataSaved, diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 105010140..7ff56860f 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -961,14 +961,6 @@ function cardClick(_, row) { transition-show="scale" transition-hide="scale" :full-width="createComplement?.isFullWidth ?? false" - @before-hide=" - () => { - if (createRef.isSaveAndContinue) { - showForm = true; - createForm.formInitialData = { ...create.formInitialData }; - } - } - " data-cy="vn-table-create-dialog" >