From 3ccdf7e6e266578b98063e898b4acca0f1d15eda Mon Sep 17 00:00:00 2001 From: ShaabanEltanany Date: Sun, 13 Sep 2020 14:16:23 +0200 Subject: keeping package changes safe give user chance to discard changes or save changes Issue-ID: CCSDK-2336 Signed-off-by: ShaabanEltanany Change-Id: If1e1c94ef65822428f25cca071103c9022add144 --- .../app/common/core/canDactivate/ComponentCanDeactivate.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts (limited to 'cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts') 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..e0dac0dc3 --- /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; + } + } +} -- cgit 1.2.3-korg