La liste des groupes affiche maintenant les permission du groupe dans ces détails.

This commit is contained in:
FyloZ 2021-03-13 13:58:57 -05:00
parent 8ca3516ae6
commit abb63a54cf
3 changed files with 11 additions and 8 deletions

View File

@ -48,7 +48,8 @@
<td mat-cell *matCellDef="let group" [attr.colspan]="columns.length">
<div class="entity-detail"
[@detailExpand]="group == expandedElement && canViewEmployee ? 'expanded' : 'collapsed'">
<cre-employees-list [group]="group" class="w-100"></cre-employees-list>
<!-- <cre-employees-list [group]="group" class="w-100"></cre-employees-list>-->
<cre-permissions-list [group]="group"></cre-permissions-list>
</div>
</td>
</ng-container>

View File

@ -1,5 +1,5 @@
<div class="d-flex flex-column">
<div class="permissions-list" *ngIf="employee.permissions">
<div class="permissions-list" *ngIf="permissions">
<p>Permissions</p>
<ng-container *ngTemplateOutlet="permissionsList; context:{permissions: permissions}"></ng-container>
</div>

View File

@ -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)
}
}