Merge pull request #757 from nickrum/leave-dialog-fix

Call navigation guard in item route component
This commit is contained in:
Rijk van Zanten
2020-10-22 20:12:48 +02:00
committed by GitHub

View File

@@ -324,9 +324,7 @@ export default defineComponent({
useShortcut('meta+shift+s', saveAndAddNew, form);
const navigationGuard: NavigationGuard = (to, from, next) => {
const hasEdits = Object.keys(edits.value).length > 0;
if (hasEdits) {
if (hasEdits.value) {
confirmLeave.value = true;
leaveTo.value = to.fullPath;
return next(false);
@@ -470,6 +468,12 @@ export default defineComponent({
return { deleteAllowed, saveAllowed, archiveAllowed, updateAllowed };
}
},
beforeRouteLeave(to, from, next) {
return (this as any).navigationGuard(to, from, next);
},
beforeRouteUpdate(to, from, next) {
return (this as any).navigationGuard(to, from, next);
},
});
</script>