forked from verdnatura/salix-front
feat: refs #6909 popup onBeforeLeave
This commit is contained in:
parent
af779f0fc2
commit
1484b7de3b
|
@ -1,6 +1,7 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||
import { onBeforeRouteLeave } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
@ -8,6 +9,7 @@ import { useStateStore } from 'stores/useStateStore';
|
|||
import { useValidator } from 'src/composables/useValidator';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||
import VnConfirm from './ui/VnConfirm.vue';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const state = useState();
|
||||
|
@ -90,6 +92,19 @@ onMounted(async () => {
|
|||
}
|
||||
});
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if (!hasChanges.value) next();
|
||||
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Unsaved changes will be lost'),
|
||||
message: t('Are you sure exit without saving?'),
|
||||
promise: () => next(),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
state.unset($props.model);
|
||||
});
|
||||
|
@ -249,3 +264,8 @@ watch(formUrl, async () => {
|
|||
padding: 32px;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
Unsaved changes will be lost: Los cambios que no haya guardado se perderán
|
||||
Are you sure exit without saving?: ¿Seguro que quiere salir sin guardar?
|
||||
</i18n>
|
||||
|
|
Loading…
Reference in New Issue