Skip to content

Commit

Permalink
fix(modif): inverse added and deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Aug 29, 2018
1 parent 0685845 commit 2fb09b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion projects/auth/src/lib/shared/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions projects/utils/src/lib/modif.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export enum ModifType {

export interface Modif {
type: ModifType;
oldValue?: any;
newValue?: any;
keysChanged?: {
key: string;
newValue: any;
Expand All @@ -24,4 +22,6 @@ export interface ModifRegroupement {
export interface ModifItem {
modif: Modif;
value: any;
oldValue?: any;
newValue?: any;
}
18 changes: 9 additions & 9 deletions projects/utils/src/lib/modif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
};
});

Expand Down

0 comments on commit 2fb09b1

Please sign in to comment.