refactor: refs #8422 add notifications for data save and delete actions
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jose Antonio Tubau 2025-03-11 13:02:20 +01:00
parent cc2e9f7890
commit f4b72c5d75
3 changed files with 14 additions and 14 deletions

View File

@ -4,6 +4,7 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
@ -12,6 +13,7 @@ import FormModelPopup from 'components/FormModelPopup.vue';
const route = useRoute();
const { t } = useI18n();
const { notify } = useNotify();
const emit = defineEmits(['onDataSaved']);
const $props = defineProps({
@ -82,6 +84,7 @@ async function save() {
const body = mapperDms(dms.value);
const response = await axios.post(getUrl(), body[0], body[1]);
emit('onDataSaved', body[1].params, response);
notify(t('globals.dataSaved'), 'positive');
delete dms.value.files;
return response;
}

View File

@ -13,10 +13,12 @@ import VnDms from 'src/components/common/VnDms.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import { useSession } from 'src/composables/useSession';
import useNotify from 'src/composables/useNotify.js';
const route = useRoute();
const quasar = useQuasar();
const { t } = useI18n();
const { notify } = useNotify();
const rows = ref([]);
const dmsRef = ref();
const formDialog = ref({});
@ -261,6 +263,7 @@ function deleteDms(dmsFk) {
await axios.post(`${$props.deleteModel ?? $props.model}/${dmsFk}/removeFile`);
const index = rows.value.findIndex((row) => row.id == dmsFk);
rows.value.splice(index, 1);
notify(t('globals.dataDeleted'), 'positive');
});
}

View File

@ -4,17 +4,14 @@ import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnRow from 'components/ui/VnRow.vue';
import FormModelPopup from 'components/FormModelPopup.vue';
import FetchData from 'components/FetchData.vue';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const emit = defineEmits(['onDataSaved']);
const { t } = useI18n();
const { notify } = useNotify();
const route = useRoute();
const dmsOptions = ref([]);
@ -30,7 +27,6 @@ const importDms = async () => {
};
await axios.post('vehicleDms', data);
notify(t('globals.dataSaved'), 'positive');
dmsId.value = null;
emit('onDataSaved');
} catch (e) {
@ -54,16 +50,14 @@ const importDms = async () => {
:save-fn="importDms"
>
<template #form-inputs>
<VnRow>
<VnSelect
:label="t('vehicle.dms.document')"
:options="dmsOptions"
hide-selected
option-label="id"
option-value="id"
v-model="dmsId"
/>
</VnRow>
<VnSelect
:label="t('vehicle.dms.document')"
:options="dmsOptions"
hide-selected
option-label="id"
option-value="id"
v-model="dmsId"
/>
</template>
</FormModelPopup>
</template>