diff --git a/libs/web/src/grids/users-grid/account-profile-form/account-profile-form.component.ts b/libs/web/src/grids/users-grid/account-profile-form/account-profile-form.component.ts index 07237708..25a852f0 100644 --- a/libs/web/src/grids/users-grid/account-profile-form/account-profile-form.component.ts +++ b/libs/web/src/grids/users-grid/account-profile-form/account-profile-form.component.ts @@ -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(); @@ -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; } diff --git a/libs/web/src/grids/users-grid/user-modal/user-modal.component.ts b/libs/web/src/grids/users-grid/user-modal/user-modal.component.ts index 28a1e0a3..99f73851 100644 --- a/libs/web/src/grids/users-grid/user-modal/user-modal.component.ts +++ b/libs/web/src/grids/users-grid/user-modal/user-modal.component.ts @@ -35,19 +35,23 @@ export class UserModalComponent extends BaseResourceModalComponent { onOk: EventEmitter = new EventEmitter(); 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(); } }