Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
fix(user-components): Add check userGroups before set/get values from…
Browse files Browse the repository at this point in the history
… its
  • Loading branch information
EndyKaufman committed Dec 18, 2017
1 parent 9baed6d commit 4bc7576
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ export class AccountProfileFormComponent extends BaseModalComponent {

init() {
super.init();
this.userGroups.user = this.item;
this.userGroups.mockedItems =
this.item.groups.map((group: any | Group) => {
return new UserGroup({
id: group.pk,
group: group
if (this.userGroups) {
this.userGroups.user = this.item;
this.userGroups.mockedItems =
this.item.groups.map((group: any | Group) => {
return new UserGroup({
id: group.pk,
group: group
});
});
});
this.userGroups.search();
this.userGroups.search();
}
}
afterCreate() {
super.afterCreate();
Expand All @@ -63,8 +65,10 @@ export class AccountProfileFormComponent extends BaseModalComponent {
return false;
}
ok() {
this.item.groups =
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
if (this.userGroups) {
this.item.groups =
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
}
this.onOk.emit(this.item);
return false;
}
Expand Down
24 changes: 14 additions & 10 deletions libs/web/src/grids/users-grid/user-modal/user-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@ export class UserModalComponent extends BaseResourceModalComponent {
onOk: EventEmitter<UserModalComponent | any> = new EventEmitter<any>();

afterOpen() {
this.userGroups.user = this.item;
this.userGroups.mockedItems =
this.item.groups.map((group: any | Group) => {
return new UserGroup({
id: group.pk,
group: group
if (this.userGroups) {
this.userGroups.user = this.item;
this.userGroups.mockedItems =
this.item.groups.map((group: any | Group) => {
return new UserGroup({
id: group.pk,
group: group
});
});
});
this.userGroups.search();
this.userGroups.search();
}
}
ok() {
this.item.groups =
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
if (this.userGroups) {
this.item.groups =
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
}
return super.ok();
}
}

0 comments on commit 4bc7576

Please # to comment.