From 06921783bf5924b94c1c14c7fed2d8669bba2168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Coun=C3=A9?= <47885707+mcoune@users.noreply.github.com> Date: Fri, 23 May 2025 11:50:38 +0200 Subject: [PATCH] AAE-33907 Adds input for 'Open next task' checkbox (#10823) * [AAE-33907] Adds input for 'Open next task' checkbox * Adds input for 'Open next task' checkbox Adds an input to the task screen component to determine whether the "Open next task" checkbox is checked by default. Also, adds an output that emits an event when the state of the "Open next task" checkbox changes. * [AAE-33907] added condition for isNextTaskCheckboxChecked * [AAE-33907] added showNextTaskCheckbox property and moved condition * Adds next task checkbox functionality. * Adds support for next task navigation * Enhances screen cloud component testing * Makes openNextTask optional for complete task * removed tests * Cleans up unnecessary blank lines in spec file * fixed unit test --- .../screen-cloud/screen-cloud.component.ts | 30 +++++++++++++++++-- .../lib/screen/models/screen-cloud.model.ts | 5 +++- .../user-task-cloud.component.html | 8 +++-- .../user-task-cloud.component.spec.ts | 2 +- .../user-task-cloud.component.ts | 6 ++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts index 849d9cf810..19f1274f87 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts @@ -21,6 +21,7 @@ import { ScreenRenderingService } from '../../../services/public-api'; import { MatCardModule } from '@angular/material/card'; import { UserTaskCustomUi } from '../../models/screen-cloud.model'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { MatCheckboxChange } from '@angular/material/checkbox'; @Component({ selector: 'adf-cloud-task-screen', @@ -68,13 +69,21 @@ export class TaskScreenCloudComponent implements OnInit { @Input() rootProcessInstanceId: string = ''; + /** Whether the `Open next task` checkbox is checked by default or not. */ + @Input() + isNextTaskCheckboxChecked = false; + + /** Toggle rendering of the `Open next task` checkbox. */ + @Input() + showNextTaskCheckbox = false; + /** Emitted when the task is saved. */ @Output() taskSaved = new EventEmitter(); /** Emitted when the task is completed. */ @Output() - taskCompleted = new EventEmitter(); + taskCompleted = new EventEmitter(); /** Emitted when there is an error. */ @Output() @@ -92,6 +101,10 @@ export class TaskScreenCloudComponent implements OnInit { @Output() unclaimTask = new EventEmitter(); + /** Emitted when the `Open next task` checkbox was toggled. */ + @Output() + nextTaskCheckboxCheckedChanged = new EventEmitter(); + @ViewChild('container', { read: ViewContainerRef, static: true }) container: ViewContainerRef; @@ -140,6 +153,12 @@ export class TaskScreenCloudComponent implements OnInit { if (this.rootProcessInstanceId && Object.prototype.hasOwnProperty.call(this.componentRef.instance, 'rootProcessInstanceId')) { this.componentRef.setInput('rootProcessInstanceId', this.rootProcessInstanceId); } + if (this.showNextTaskCheckbox && Object.prototype.hasOwnProperty.call(this.componentRef.instance, 'showNextTaskCheckbox')) { + this.componentRef.setInput('showNextTaskCheckbox', this.showNextTaskCheckbox); + } + if (this.isNextTaskCheckboxChecked && Object.prototype.hasOwnProperty.call(this.componentRef.instance, 'isNextTaskCheckboxChecked')) { + this.componentRef.setInput('isNextTaskCheckboxChecked', this.isNextTaskCheckboxChecked); + } } subscribeToOutputs() { @@ -147,7 +166,9 @@ export class TaskScreenCloudComponent implements OnInit { this.componentRef.instance.taskSaved.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.taskSaved.emit()); } if (this.componentRef.instance?.taskCompleted) { - this.componentRef.instance.taskCompleted.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.taskCompleted.emit()); + this.componentRef.instance.taskCompleted + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((openNextTask) => this.taskCompleted.emit(openNextTask)); } if (this.componentRef.instance?.error) { this.componentRef.instance.error.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((data) => this.error.emit(data)); @@ -162,6 +183,11 @@ export class TaskScreenCloudComponent implements OnInit { if (this.componentRef.instance?.cancelTask) { this.componentRef.instance.cancelTask.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((data) => this.cancelTask.emit(data)); } + if (this.componentRef.instance?.nextTaskCheckboxCheckedChanged) { + this.componentRef.instance.nextTaskCheckboxCheckedChanged + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((data) => this.nextTaskCheckboxCheckedChanged.emit(data)); + } } switchToDisplayMode(newDisplayMode?: string) { diff --git a/lib/process-services-cloud/src/lib/screen/models/screen-cloud.model.ts b/lib/process-services-cloud/src/lib/screen/models/screen-cloud.model.ts index e4e924541c..299458ccba 100644 --- a/lib/process-services-cloud/src/lib/screen/models/screen-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/screen/models/screen-cloud.model.ts @@ -27,11 +27,14 @@ export interface UserTaskCustomUi { showCancelButton: boolean; taskName: string; taskId: string; + isNextTaskCheckboxChecked: boolean; + showNextTaskCheckbox: boolean; cancelTask: EventEmitter; claimTask: EventEmitter; error: EventEmitter; switchToDisplayMode?: (newDisplayMode?: string) => void; - taskCompleted: EventEmitter; + taskCompleted: EventEmitter; taskSaved: EventEmitter; unclaimTask: EventEmitter; + nextTaskCheckboxCheckedChanged: EventEmitter; } diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html index b4ef90b183..2ec904ff5a 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html +++ b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html @@ -1,4 +1,4 @@ -
+
@@ -38,12 +38,16 @@ [showCancelButton]="showCancelButton" [taskName]="taskDetails.name" [taskId]="taskId" + [showNextTaskCheckbox]="showNextTaskCheckbox && canCompleteTask()" + [isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked" + (cancelTask)="onCancelClick()" (claimTask)="onClaimTask()" (error)="onError($event)" - (taskCompleted)="onCompleteTask()" + (taskCompleted)="onCompleteTask($event)" (taskSaved)="onFormSaved()" (unclaimTask)="onUnclaimTask()" + (nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)" /> diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.spec.ts index d8a386334e..8f35bd8a18 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.spec.ts @@ -334,7 +334,7 @@ describe('UserTaskCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - expect(component.taskCompleted.emit).toHaveBeenCalledOnceWith('task1'); + expect(component.taskCompleted.emit).toHaveBeenCalledOnceWith(false); }); it('should emit taskClaimed when task is claimed', async () => { diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts index cc80170e55..531be22d97 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts @@ -150,7 +150,7 @@ export class UserTaskCloudComponent implements OnInit, OnChanges { /** Emitted when the task is completed. */ @Output() - taskCompleted = new EventEmitter(); + taskCompleted = new EventEmitter(); candidateUsers: string[] = []; candidateGroups: string[] = []; @@ -242,9 +242,9 @@ export class UserTaskCloudComponent implements OnInit, OnChanges { this.taskClaimed.emit(this.taskId); } - onCompleteTask(): void { + onCompleteTask(openNextTask: boolean = false): void { this.loadTask(); - this.taskCompleted.emit(this.taskId); + this.taskCompleted.emit(openNextTask); } onCompleteTaskForm(): void {