diff --git a/src/app/modules/groups/pages/list/list.component.html b/src/app/modules/groups/pages/list/list.component.html index 302a5a6..3234e68 100644 --- a/src/app/modules/groups/pages/list/list.component.html +++ b/src/app/modules/groups/pages/list/list.component.html @@ -48,7 +48,8 @@
- + +
diff --git a/src/app/modules/shared/components/permissions-list/permissions-list.component.html b/src/app/modules/shared/components/permissions-list/permissions-list.component.html index 530ebfb..7077bda 100644 --- a/src/app/modules/shared/components/permissions-list/permissions-list.component.html +++ b/src/app/modules/shared/components/permissions-list/permissions-list.component.html @@ -1,5 +1,5 @@
-
+

Permissions

diff --git a/src/app/modules/shared/components/permissions-list/permissions-list.component.ts b/src/app/modules/shared/components/permissions-list/permissions-list.component.ts index 837edd0..7595864 100644 --- a/src/app/modules/shared/components/permissions-list/permissions-list.component.ts +++ b/src/app/modules/shared/components/permissions-list/permissions-list.component.ts @@ -1,13 +1,14 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {Employee, EmployeePermission, mapped_permissions} from "../../model/employee"; +import {Component, Input, OnInit} from '@angular/core' +import {Employee, EmployeeGroup, EmployeePermission, mapped_permissions} from '../../model/employee' @Component({ selector: 'cre-permissions-list', templateUrl: './permissions-list.component.html', styleUrls: ['./permissions-list.component.sass'] }) -export class PermissionsListComponent implements OnInit { +export class PermissionsListComponent { @Input() employee: Employee + @Input() group: EmployeeGroup // @ts-ignore private _permissions = Object.values(mapped_permissions).flatMap(p => p) @@ -15,10 +16,11 @@ export class PermissionsListComponent implements OnInit { constructor() { } - ngOnInit(): void { + get permissions(): EmployeePermission[] { + return this.filterPermissions(this.employee ? this.employee.permissions : this.group.permissions) } - get permissions(): EmployeePermission[] { - return this._permissions.filter(p => this.employee.permissions.indexOf(p.permission) >= 0).map(p => p.description) + private filterPermissions(permissions: EmployeePermission[]) { + return this._permissions.filter(p => permissions.indexOf(p.permission) >= 0).map(p => p.description) } }