Skip to content

Commit

Permalink
Arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamorel committed Apr 12, 2023
1 parent 8e87f49 commit c551b61
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frontend/src/components/object/ObjectPermission.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ const updateObjectPermission = (value: boolean, userId: string, permCode: string
const userPerms: UserPermissions = getMappedObjectToUserPermissions.value
.find( (x: UserPermissions) => x.userId === userId ) as UserPermissions;
// Due to 2-way binding we check if there are no managers left when MANAGE is unticked
const noManagers = permCode === Permissions.MANAGE && !managers.length;
// When READ is unticked check if they are the last remaining user with MANAGE
const lastManager = permCode === Permissions.READ && managers.length === 1 && userPerms.manage;
const lastManager = () => permCode === Permissions.READ && managers.length === 1 && userPerms.manage;
// Due to 2-way binding we check if there are no managers left when MANAGE is unticked
const noManagers = () => permCode === Permissions.MANAGE && !managers.length;
// Disallow removable of final MANAGE permission
if( noManagers || lastManager ) {
if( lastManager() || noManagers() ) {
removeManageAlert.show();
if( permCode === Permissions.MANAGE ) userPerms.manage = true;
if( permCode === Permissions.READ ) userPerms.read = true;
if( permCode === Permissions.MANAGE ) userPerms.manage = true;
}
else {
permissionStore.deleteObjectPermission(props.objectId, userId, permCode);
Expand Down

0 comments on commit c551b61

Please sign in to comment.