Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

fix(ability): can't edit reports if verified and reviewer #624

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions app/abilities/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ export default Ability.extend({
function() {
const isEditable =
this.get("user.isSuperuser") ||
(!(this.get("model.verifiedBy.id") || this.get("model.billed")) &&
(!this.get("model.verifiedBy.id") &&
(this.get("model.user.id") === this.get("user.id") ||
(this.get("model.user.supervisors") ?? [])
.mapBy("id")
.includes(this.get("user.id"))));
const isReviewer = (this.get("model.taskAssignees") ?? [])
.concat(
this.get("model.projectAssignees") ?? [],
this.get("model.customerAssignees") ?? []
)
.mapBy("user.id")
.includes(this.get("user.id"));
const isReviewer =
(this.get("model.taskAssignees") ?? [])
.concat(
this.get("model.projectAssignees") ?? [],
this.get("model.customerAssignees") ?? []
)
.mapBy("user.id")
.includes(this.get("user.id")) && !this.get("model.verifiedBy.id");
return isEditable || isReviewer;
}
)
Expand Down