Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix(component): fix the editable comment when archived
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Nov 14, 2022
1 parent 1959ad7 commit 0553dec
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion components/comment/multiviewer/viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
@update:model-value="switchVote"/>
</section>
<UpdateCommentField
v-else
v-if="mayUpdateComment"
:model-value="comment"
@update:model-value="closeUpdateCommentField"/>
</template>
Expand Down Expand Up @@ -139,6 +139,9 @@ import {
ARCHIVE_AND_RESTORE_PERSONAL_COMMENT_ON_OWN_DEPARTMENT,
ARCHIVE_AND_RESTORE_SOCIAL_COMMENT_ON_OWN_DEPARTMENT,
ARCHIVE_AND_RESTORE_PUBLIC_COMMENT_ON_ANY_DEPARTMENT,
UPDATE_PERSONAL_COMMENT_ON_OWN_DEPARTMENT,
UPDATE_PUBLIC_COMMENT_ON_ANY_DEPARTMENT,
UPDATE_SOCIAL_COMMENT_ON_OWN_DEPARTMENT,
VOTE_PERSONAL_COMMENT_ON_OWN_DEPARTMENT,
VOTE_SOCIAL_COMMENT_ON_OWN_DEPARTMENT,
VOTE_PUBLIC_COMMENT_ON_ANY_DEPARTMENT
Expand Down Expand Up @@ -354,6 +357,33 @@ function closeUpdateCommentField(newComment: DeserializedCommentResource<"user">
closeUpdateField()
}
const mayUpdateComment = computed<boolean>(() => {
const user = props.modelValue.user as DeserializedUserDocument<"department">
const isLimitedPersonalScope = permissionGroup.hasOneRoleAllowed(userProfile.data.roles.data, [
UPDATE_PERSONAL_COMMENT_ON_OWN_DEPARTMENT
]) && user.data.id === userProfile.data.id
const departmentID = user.data.department.data.id
const isLimitedUpToDepartmentScope = !isLimitedPersonalScope
&& permissionGroup.hasOneRoleAllowed(userProfile.data.roles.data, [
UPDATE_SOCIAL_COMMENT_ON_OWN_DEPARTMENT
]) && user.data.department.data.id === departmentID
const isLimitedUpToGlobalScope = !isLimitedUpToDepartmentScope
&& permissionGroup.hasOneRoleAllowed(userProfile.data.roles.data, [
UPDATE_PUBLIC_COMMENT_ON_ANY_DEPARTMENT
])
const isPermitted = isLimitedPersonalScope
|| isLimitedUpToDepartmentScope
|| isLimitedUpToGlobalScope
const isDeleted = props.modelValue.deletedAt
const mayViewPresent = !isDeleted
return mustUpdate.value && isPermitted && mayViewPresent
})
const {
"state": mustArchive,
"on": confirmArchive,
Expand Down

0 comments on commit 0553dec

Please sign in to comment.