diff --git a/docs/task-details.component.md b/docs/task-details.component.md index b1d7596e62..0d822b52b7 100644 --- a/docs/task-details.component.md +++ b/docs/task-details.component.md @@ -46,6 +46,8 @@ Shows the details of the task id passed in input | error | `EventEmitter` | Emitted when an error occurs. | | executeOutcome | `EventEmitter` | Emitted when any outcome is executed. Default behaviour can be prevented via `event.preventDefault()`. | | assignTask | `EventEmitter` | Emitted when a task is assigned. | +| claimedTask | `EventEmitter` | Emitted when a task is claimed. | +| unClaimedTask | `EventEmitter` | Emitted when a task is unclaimed. | ## Details diff --git a/lib/process-services/task-list/components/task-details.component.html b/lib/process-services/task-list/components/task-details.component.html index fbb59c934a..d91272b024 100644 --- a/lib/process-services/task-list/components/task-details.component.html +++ b/lib/process-services/task-list/components/task-details.component.html @@ -69,7 +69,7 @@ [taskDetails]="taskDetails" [formName]="taskFormName" (claim)="onClaimAction($event)" - (unclaim)="onClaimAction($event)"> + (unclaim)="onUnclaimAction($event)"> { expect(getTaskDetailsSpy).not.toHaveBeenCalled(); }); + it('should send a claim task event when a task is claimed', async(() => { + component.claimedTask.subscribe((taskId) => { + expect(taskId).toBe('FAKE-TASK-CLAIM'); + }); + component.onClaimAction('FAKE-TASK-CLAIM'); + })); + + it('should send a unclaim task event when a task is unclaimed', async(() => { + component.claimedTask.subscribe((taskId) => { + expect(taskId).toBe('FAKE-TASK-UNCLAIM'); + }); + component.onUnclaimAction('FAKE-TASK-UNCLAIM'); + })); + it('should set a placeholder message when taskId not initialised', () => { fixture.detectChanges(); expect(fixture.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.MESSAGES.NONE'); diff --git a/lib/process-services/task-list/components/task-details.component.ts b/lib/process-services/task-list/components/task-details.component.ts index b1ed92a6e7..46aa58ccd0 100644 --- a/lib/process-services/task-list/components/task-details.component.ts +++ b/lib/process-services/task-list/components/task-details.component.ts @@ -160,6 +160,14 @@ export class TaskDetailsComponent implements OnInit, OnChanges { @Output() assignTask: EventEmitter = new EventEmitter(); + /** Emitted when a task is claimed. */ + @Output() + claimedTask: EventEmitter = new EventEmitter(); + + /** Emitted when a task is unclaimed. */ + @Output() + unClaimedTask: EventEmitter = new EventEmitter(); + taskDetails: TaskDetailsModel; taskFormName: string = null; @@ -375,6 +383,12 @@ export class TaskDetailsComponent implements OnInit, OnChanges { } onClaimAction(taskId: string): void { + this.claimedTask.emit(taskId); + this.loadDetails(taskId); + } + + onUnclaimAction(taskId: string): void { + this.unClaimedTask.emit(taskId); this.loadDetails(taskId); }