From abb63a54cf4c3bc9c098c0fec8d3835a845e5c59 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 13:58:57 -0500 Subject: [PATCH] =?UTF-8?q?La=20liste=20des=20groupes=20affiche=20maintena?= =?UTF-8?q?nt=20les=20permission=20du=20groupe=20dans=20ces=20d=C3=A9tails?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/groups/pages/list/list.component.html | 3 ++- .../permissions-list.component.html | 2 +- .../permissions-list/permissions-list.component.ts | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) 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) } }