Skip to content

Commit

Permalink
integration of codeRabitai suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmbabhazi committed Oct 25, 2024
1 parent 97995ec commit 0ac3f94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ export class EditEmployeeOtherSettingsComponent implements OnInit, OnDestroy {
timeZone: [],
timeFormat: [],
upworkId: [],
linkedInId: [],
allowManualTime: [],
allowModifyTime: [],
allowDeleteTime: [],
allowScreenshotCapture: []
allowManualTime: [false],
allowModifyTime: [false],
allowDeleteTime: [false],
allowScreenshotCapture: [true]
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ export class TimeTrackingAuthorizedDirective implements OnInit {
this._store.user$.pipe(
filter((user: IUser) => !!user),
map((user: IUser) => {
const permissions = Array.isArray(this.permission) ? this.permission : [this.permission];

const hasPermissions = (source: any) =>
permissions.every((permission) => {
const permKey = camelcase(permission);
return permKey in source && source[permKey];
});

const hasOrgPermission = hasPermissions(organization);

if (user.employee) {
// Check if the permission is in the organization and in the employee properties
return (
camelcase(this.permission) in organization &&
organization[camelcase(this.permission)] &&
camelcase(this.permission) in user.employee &&
user.employee[camelcase(this.permission)]
);
const hasEmployeePermission = hasPermissions(user.employee);
return hasOrgPermission && hasEmployeePermission;
} else {
return (
camelcase(this.permission) in organization &&
organization[camelcase(this.permission)]
);
return hasOrgPermission;
}
})
)
Expand Down

0 comments on commit 0ac3f94

Please sign in to comment.