refactor: refs #8372 update FormModelPopup to use props for save and continue logic
This commit is contained in:
parent
30532c9eab
commit
09b613cac1
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
>
|
||||
<FormModelPopup
|
||||
|
|
Loading…
Reference in New Issue