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

Commit 4bc7576

Browse files
committed
fix(user-components): Add check userGroups before set/get values from its
1 parent 9baed6d commit 4bc7576

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

libs/web/src/grids/users-grid/account-profile-form/account-profile-form.component.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ export class AccountProfileFormComponent extends BaseModalComponent {
3838

3939
init() {
4040
super.init();
41-
this.userGroups.user = this.item;
42-
this.userGroups.mockedItems =
43-
this.item.groups.map((group: any | Group) => {
44-
return new UserGroup({
45-
id: group.pk,
46-
group: group
41+
if (this.userGroups) {
42+
this.userGroups.user = this.item;
43+
this.userGroups.mockedItems =
44+
this.item.groups.map((group: any | Group) => {
45+
return new UserGroup({
46+
id: group.pk,
47+
group: group
48+
});
4749
});
48-
});
49-
this.userGroups.search();
50+
this.userGroups.search();
51+
}
5052
}
5153
afterCreate() {
5254
super.afterCreate();
@@ -63,8 +65,10 @@ export class AccountProfileFormComponent extends BaseModalComponent {
6365
return false;
6466
}
6567
ok() {
66-
this.item.groups =
67-
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
68+
if (this.userGroups) {
69+
this.item.groups =
70+
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
71+
}
6872
this.onOk.emit(this.item);
6973
return false;
7074
}

libs/web/src/grids/users-grid/user-modal/user-modal.component.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,23 @@ export class UserModalComponent extends BaseResourceModalComponent {
3535
onOk: EventEmitter<UserModalComponent | any> = new EventEmitter<any>();
3636

3737
afterOpen() {
38-
this.userGroups.user = this.item;
39-
this.userGroups.mockedItems =
40-
this.item.groups.map((group: any | Group) => {
41-
return new UserGroup({
42-
id: group.pk,
43-
group: group
38+
if (this.userGroups) {
39+
this.userGroups.user = this.item;
40+
this.userGroups.mockedItems =
41+
this.item.groups.map((group: any | Group) => {
42+
return new UserGroup({
43+
id: group.pk,
44+
group: group
45+
});
4446
});
45-
});
46-
this.userGroups.search();
47+
this.userGroups.search();
48+
}
4749
}
4850
ok() {
49-
this.item.groups =
50-
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
51+
if (this.userGroups) {
52+
this.item.groups =
53+
this.userGroups.mockedItems.map((userGroup: UserGroup) => userGroup.group);
54+
}
5155
return super.ok();
5256
}
5357
}

0 commit comments

Comments
 (0)