Explorar o código

add the before you leave message before leaving the page

Olivier Massot %!s(int64=2) %!d(string=hai) anos
pai
achega
36448e96e3
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      components/Ui/Form.vue

+ 8 - 0
components/Ui/Form.vue

@@ -326,6 +326,14 @@ onBeforeRouteLeave((to: RouteLocationNormalized, from: RouteLocationNormalized)
   return true
 });
 
+onMounted(() => {
+  window.addEventListener('beforeunload', (event) => {
+    if (formStore.dirty === true) {
+      event.returnValue = i18n.t('quit_without_saving_warning')
+    }
+  })
+})
+
 /**
  * Quitte le formulaire sans enregistrer
  */