From 9ec04d33d4d4480c98237629b1e92e410dcce7e1 Mon Sep 17 00:00:00 2001 From: Vito Date: Thu, 13 Aug 2020 09:02:28 +0100 Subject: [PATCH] [ADF-5165] - added involved user for task (#5985) Co-authored-by: Vito Albano --- .../task-form/task-form.component.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts index 907e559d99..89bea13441 100644 --- a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts @@ -28,7 +28,7 @@ import { } from '@alfresco/adf-core'; import { TaskDetailsModel } from '../../models/task-details.model'; import { TaskListService } from '../../services/tasklist.service'; -import { UserRepresentation } from '@alfresco/js-api'; +import { UserRepresentation, LightUserRepresentation } from '@alfresco/js-api'; import { Observable } from 'rxjs'; import { ProcessFormRenderingService } from '../../../form/process-form-rendering.service'; @@ -281,12 +281,29 @@ export class TaskFormComponent implements OnInit { if (this.isCandidateMember()) { readOnlyForm = this.internalReadOnlyForm || !this.isAssignedToMe(); } else { - readOnlyForm = this.internalReadOnlyForm || !(this.isAssignedToMe() || (this.canInitiatorComplete() && this.isProcessInitiator())); + readOnlyForm = this.internalReadOnlyForm || !(this.isAssignedToMe() || this.canCurrentUserAsInitiatorComplete() || this.isCurrentUserInvolved()); } return readOnlyForm; } + isCurrentUserInvolved(): boolean { + let isInvolved = false; + if (this.taskDetails.involvedPeople && this.currentLoggedUser) { + const userInvolved = this.taskDetails.involvedPeople.find( + (involvedUser: LightUserRepresentation) => + involvedUser.email.toLocaleLowerCase() === this.currentLoggedUser.email.toLocaleLowerCase() || + involvedUser.id + '' === this.currentLoggedUser.externalId + ); + isInvolved = !!userInvolved; + } + return isInvolved; + } + + canCurrentUserAsInitiatorComplete(): boolean { + return this.canInitiatorComplete() && this.isProcessInitiator(); + } + isProcessInitiator(): boolean { return this.currentLoggedUser && ( this.currentLoggedUser.id === +this.taskDetails.processInstanceStartUserId); }