diff options
author | 2020-09-13 14:16:23 +0200 | |
---|---|---|
committer | 2020-09-13 14:16:23 +0200 | |
commit | 3ccdf7e6e266578b98063e898b4acca0f1d15eda (patch) | |
tree | 0e0d562eea0b7d96990ca6e1c9b704dcd670a901 /cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivateGuard.ts | |
parent | 8de37f9d3035b4a41e696b967f2222806c250925 (diff) |
keeping package changes safe
give user chance to discard changes or save changes
Issue-ID: CCSDK-2336
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: If1e1c94ef65822428f25cca071103c9022add144
Diffstat (limited to 'cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivateGuard.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivateGuard.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivateGuard.ts b/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivateGuard.ts new file mode 100644 index 000000000..b24784262 --- /dev/null +++ b/cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivateGuard.ts @@ -0,0 +1,19 @@ +import {Injectable} from '@angular/core'; + +import {CanDeactivate} from '@angular/router'; +import {ComponentCanDeactivate} from './ComponentCanDeactivate'; + +@Injectable() +export class ComponentCanDeactivateGuard implements CanDeactivate<ComponentCanDeactivate> { + canDeactivate(component: ComponentCanDeactivate): boolean { + + if (component.canDeactivate()) { + if (confirm('You have unsaved changes! If you leave, your changes will be lost.')) { + return true; + } else { + return false; + } + } + return true; + } +} |