summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts')
-rw-r--r--cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts b/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts
new file mode 100644
index 000000000..3435b10d3
--- /dev/null
+++ b/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts
@@ -0,0 +1,14 @@
+import {HostListener} from '@angular/core';
+
+export abstract class ComponentCanDeactivate {
+
+ abstract canDeactivate(): boolean;
+
+
+ @HostListener('window:beforeunload', ['$event'])
+ unloadNotification($event: any) {
+ if (this.canDeactivate()) {
+ $event.returnValue = true;
+ }
+ }
+}