From 2fb09b13f0218cbb248e2d24dced77e6b8799fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 29 Aug 2018 16:30:54 -0400 Subject: [PATCH] fix(modif): inverse added and deleted --- projects/auth/src/lib/shared/auth.guard.ts | 2 +- projects/utils/src/lib/modif.interface.ts | 4 ++-- projects/utils/src/lib/modif.ts | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/projects/auth/src/lib/shared/auth.guard.ts b/projects/auth/src/lib/shared/auth.guard.ts index a884bfbba4..2573e6026b 100644 --- a/projects/auth/src/lib/shared/auth.guard.ts +++ b/projects/auth/src/lib/shared/auth.guard.ts @@ -27,7 +27,7 @@ export class AuthGuard implements CanActivate { this.authService.redirectUrl = state.url; const authConfig = this.config.getConfig('auth'); - if (authConfig.loginRoute) { + if (authConfig && authConfig.loginRoute) { this.router.navigateByUrl(authConfig.loginRoute); } diff --git a/projects/utils/src/lib/modif.interface.ts b/projects/utils/src/lib/modif.interface.ts index 2a572d89c7..38a5a03ae9 100644 --- a/projects/utils/src/lib/modif.interface.ts +++ b/projects/utils/src/lib/modif.interface.ts @@ -6,8 +6,6 @@ export enum ModifType { export interface Modif { type: ModifType; - oldValue?: any; - newValue?: any; keysChanged?: { key: string; newValue: any; @@ -24,4 +22,6 @@ export interface ModifRegroupement { export interface ModifItem { modif: Modif; value: any; + oldValue?: any; + newValue?: any; } diff --git a/projects/utils/src/lib/modif.ts b/projects/utils/src/lib/modif.ts index e6029cbb2d..bb8ad38689 100644 --- a/projects/utils/src/lib/modif.ts +++ b/projects/utils/src/lib/modif.ts @@ -24,8 +24,8 @@ export class ModifUtils { const index = obj2Clone.findIndex(s => s.id === fromItem.id); if (index === -1) { - items.added.push({ - modif: { type: ModifType.ADDED }, + items.deleted.push({ + modif: { type: ModifType.DELETED }, value: fromItem }); continue; @@ -46,19 +46,19 @@ export class ModifUtils { items.modified.push({ modif: { type: ModifType.MODIFIED, - keysChanged: keysChanged, - oldValue: fromItemClone, - newValue: toItemClone + keysChanged: keysChanged }, - value: fromItem + value: fromItem, + oldValue: fromItemClone, + newValue: toItemClone }); } } - items.deleted = obj2Clone.map(itemDeleted => { + items.added = obj2Clone.map(itemAdded => { return { - modif: { type: ModifType.DELETED }, - value: itemDeleted + modif: { type: ModifType.ADDED }, + value: itemAdded }; });