7525-devToTest #419

Merged
alexm merged 177 commits from 7525-devToTest into test 2024-06-04 08:06:27 +00:00
3 changed files with 13 additions and 21 deletions
Showing only changes of commit b6638e3545 - Show all commits

View File

@ -179,7 +179,7 @@ async function fetch() {
} }
} }
async function save(emit = true) { async function save() {
if ($props.observeFormChanges && !hasChanges.value) if ($props.observeFormChanges && !hasChanges.value)
return notify('globals.noChanges', 'negative'); return notify('globals.noChanges', 'negative');
@ -199,7 +199,7 @@ async function save(emit = true) {
hasChanges.value = false; hasChanges.value = false;
isLoading.value = false; isLoading.value = false;
if (emit) updateAndEmit(response?.data, 'onDataSaved'); updateAndEmit(response?.data, 'onDataSaved');
} catch (err) { } catch (err) {
console.error(err); console.error(err);
notify('errors.writeRequest', 'negative'); notify('errors.writeRequest', 'negative');
@ -207,7 +207,7 @@ async function save(emit = true) {
} }
async function saveAndGo() { async function saveAndGo() {
await save(null); await save();
push({ path: $props.goTo }); push({ path: $props.goTo });
} }
@ -242,7 +242,7 @@ function updateAndEmit(val, evt) {
emit(evt, state.get($props.model)); emit(evt, state.get($props.model));
} }
defineExpose({ save, saveAndGo, isLoading, hasChanges }); defineExpose({ save, isLoading, hasChanges });
</script> </script>
<template> <template>
<div class="column items-center full-width"> <div class="column items-center full-width">

View File

@ -56,7 +56,7 @@ onBeforeMount(async () => {
}); });
store = arrayData.store; store = arrayData.store;
entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data)); entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data));
// It enables to load data only once if the module is the same as the dataKey
if ($props.dataKey !== useRoute().meta.moduleName) await getData(); if ($props.dataKey !== useRoute().meta.moduleName) await getData();
watch( watch(
() => [$props.url, $props.filter], () => [$props.url, $props.filter],
@ -99,12 +99,7 @@ const emit = defineEmits(['onFetch']);
{{ t('components.smartCard.openSummary') }} {{ t('components.smartCard.openSummary') }}
</QTooltip> </QTooltip>
</QBtn> </QBtn>
<RouterLink <RouterLink :to="{ name: `${module}Summary`, params: { id: entity.id } }">
:to="{
name: `${module}Summary`,
params: { id: entity.id },
}"
>
<QBtn <QBtn
class="link" class="link"
color="white" color="white"

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import { ref, reactive, computed, onBeforeMount, watch } from 'vue'; import { ref, reactive, computed, onBeforeMount } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter, onBeforeRouteLeave } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import axios from 'axios'; import axios from 'axios';
@ -135,14 +135,11 @@ onBeforeMount(async () => {
totalAmount.value = data.totalDueDay; totalAmount.value = data.totalDueDay;
}); });
watch( onBeforeRouteLeave(async (to, from) => {
() => currentRoute.value.params.id,
async (newId) => {
invoiceInCorrection.correcting.length = 0; invoiceInCorrection.correcting.length = 0;
invoiceInCorrection.corrected = null; invoiceInCorrection.corrected = null;
if (newId) await setInvoiceCorrection(entityId.value); if (to.params.id !== from.params.id) await setInvoiceCorrection(entityId.value);
} });
);
async function setInvoiceCorrection(id) { async function setInvoiceCorrection(id) {
const [{ data: correctingData }, { data: correctedData }] = await Promise.all([ const [{ data: correctingData }, { data: correctedData }] = await Promise.all([