disable componetCanDeactivate with some functionality 31/112731/4
authorShaabanEltanany <shaaban.eltanany.ext@orange.com>
Wed, 16 Sep 2020 07:49:11 +0000 (09:49 +0200)
committerShaabanEltanany <shaaban.eltanany.ext@orange.com>
Wed, 16 Sep 2020 13:07:37 +0000 (15:07 +0200)
Issue-ID: CCSDK-2739
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: Ic3f3905b062f42365c8d7eed22d0ee9504906ee5

cds-ui/designer-client/src/app/app-routing.module.ts
cds-ui/designer-client/src/app/common/core/canDactivate/ComponentCanDeactivate.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts

index 2610dc5..d0a8e2a 100644 (file)
@@ -20,13 +20,17 @@ limitations under the License.
 */
 
 import {NgModule} from '@angular/core';
-import {Routes, RouterModule} from '@angular/router';
+import {RouterModule, Routes} from '@angular/router';
 
 const routes: Routes = [
-    {path: 'packages',
-     loadChildren: './modules/feature-modules/packages/packages.module#PackagesModule'},
-    {path: 'resource-dictionary',
-     loadChildren: './modules/feature-modules/resource-dictionary/resource-dictionary.module#ResourceDictionaryModule'},
+    {
+        path: 'packages',
+        loadChildren: './modules/feature-modules/packages/packages.module#PackagesModule'
+    },
+    {
+        path: 'resource-dictionary',
+        loadChildren: './modules/feature-modules/resource-dictionary/resource-dictionary.module#ResourceDictionaryModule'
+    },
     // { path: '', component: MainAppComponent },
     {
         path: '',
@@ -36,7 +40,7 @@ const routes: Routes = [
 ];
 
 @NgModule({
-    imports: [RouterModule.forRoot(routes)],
+    imports: [RouterModule.forRoot(routes, {useHash: true})],
     exports: [RouterModule]
 })
 export class AppRoutingModule {
index e0dac0d..3435b10 100644 (file)
@@ -7,7 +7,7 @@ export abstract class ComponentCanDeactivate {
 
     @HostListener('window:beforeunload', ['$event'])
     unloadNotification($event: any) {
-        if (!this.canDeactivate()) {
+        if (this.canDeactivate()) {
             $event.returnValue = true;
         }
     }
index a4a1137..449312f 100644 (file)
@@ -217,6 +217,8 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
                         if (bluePrintDetailModels) {
                             const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1];
                             this.toastService.info('package updated successfully ');
+                            this.isSaveEnabled = false;
+                            this.id = id;
                             this.router.navigate(['/packages/package/' + id]);
                         }
                     }, error => {
@@ -230,6 +232,7 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
         this.configurationDashboardService.deletePackage(this.id).subscribe(res => {
             console.log('Deleted');
             console.log(res);
+            this.isSaveEnabled = false;
             this.router.navigate(['/packages']);
         }, err => {
             console.log(err);
@@ -316,6 +319,7 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
                 this.packageCreationService.deploy(blob).subscribe(response => {
                     this.toastService.info('deployed successfully ');
                     const id = response.toString().split('id')[1].split(':')[1].split('"')[1];
+                    this.isSaveEnabled = false;
                     this.router.navigate(['/packages/package/' + id]);
                 });
             }, error => {
index d2f2e0a..6b29ec4 100644 (file)
@@ -128,6 +128,7 @@ export class PackageCreationComponent extends ComponentCanDeactivate implements
                         if (bluePrintDetailModels) {
                             const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1];
                             this.toastService.info('package updated successfully ');
+                            this.isSaveEnabled = false;
                             this.router.navigate(['/packages/package/' + id]);
                         }
                     }, error => {