mirror of
https://github.com/nasa/openmct.git
synced 2025-04-09 12:21:25 +00:00
[Edit] Check for route changes
Respond to route changes via mct-before-unload, in order to show a prompt to allow the user to confirm navigation changes which do not trigger onbeforeunload (such as using back to change the hash route). WTD-1035.
This commit is contained in:
parent
5ef382d159
commit
dc7d504691
@ -43,6 +43,17 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
// Show a dialog before allowing a location change
|
||||
function checkLocationChange(event) {
|
||||
// Get an unload message (if any)
|
||||
var warning = unload();
|
||||
// Prompt the user if there's an unload message
|
||||
if (warning && !$window.confirm(warning)) {
|
||||
// ...and prevent the route change if it was confirmed
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first active instance of this directive,
|
||||
// register as the window's beforeunload handler
|
||||
if (unloads.length === 0) {
|
||||
@ -54,6 +65,9 @@ define(
|
||||
|
||||
// Remove it when the scope is destroyed
|
||||
scope.$on("$destroy", removeUnload);
|
||||
|
||||
// Also handle route changes
|
||||
scope.$on("$locationChangeStart", checkLocationChange);
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user