diff --git a/src/components/common/FormModel.vue b/src/components/common/FormModel.vue index be7ae1c4..fc5d1217 100644 --- a/src/components/common/FormModel.vue +++ b/src/components/common/FormModel.vue @@ -133,14 +133,15 @@ async function fetch() { } } -async function submit() { +const submitForm = async evt => { + const isFormValid = await formModelRef.value.validate(); + if (isFormValid) await save(evt); +}; + +async function save() { if (props.observeFormChanges && !hasChanges.value) return notify('noChanges', 'negative'); - const isValid = await formModelRef.value.validate(); - console.log('isValid', isValid); - if (!isValid) return; - isLoading.value = true; try { const body = props.mapper @@ -149,10 +150,9 @@ async function submit() { const method = props.urlCreate ? 'post' : 'patch'; const url = props.urlCreate || props.urlUpdate || props.url; - let response; - - if (props.saveFn) await props.saveFn(body); - else await api[method](url, body); + await Promise.resolve( + props.saveFn ? props.saveFn(body) : api[method](url, body) + ); onSubmitSuccess(); hasChanges.value = false; @@ -163,18 +163,13 @@ async function submit() { defineExpose({ formData, - submit + submitForm }); diff --git a/src/pages/Account/AddressDetails.vue b/src/pages/Account/AddressDetails.vue index 362bc95d..caf7265f 100644 --- a/src/pages/Account/AddressDetails.vue +++ b/src/pages/Account/AddressDetails.vue @@ -110,6 +110,7 @@ onMounted(async () => { :form-initial-data="editAddressData" :title="t(isEditMode ? 'editAddress' : 'addAddress')" @on-data-saved="goBack()" + :show-bottom-actions="false" >