Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 8x 8x 3x 2x 2x 4x 1x 2x 2x 1x 2x 2x 1x | import { Injectable } from '@angular/core'; import { B2bRoleData } from './b2b-role.interface'; import { B2bRole } from './b2b-role.model'; @Injectable({ providedIn: 'root' }) export class B2bRoleMapper { fromData(b2bRolesData: B2bRoleData[]): B2bRole[] { if (b2bRolesData) { return this.removeFixedFromOther( b2bRolesData.map(role => ({ id: role.roleID, fixed: role.fixed, displayName: role.roleDisplayName, description: role.roleDescription, permissionDisplayNames: role.permissions.map(p => p.permissionDisplayName), })) ); } else { throw new Error(`b2bRolesData is required`); } } private removeFixedFromOther(roles: B2bRole[]): B2bRole[] { const fixedPermission = roles .filter(r => r.fixed) .reduce((acc, role) => [...acc, ...role.permissionDisplayNames], []); return roles.map(role => role.fixed ? role : { ...role, permissionDisplayNames: role.permissionDisplayNames.filter(p => !fixedPermission.includes(p)) } ); } } |