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
This commit is contained in:
Michael Couné
2025-05-23 11:50:38 +02:00
committed by GitHub
parent 1462560e6e
commit 06921783bf
5 changed files with 42 additions and 9 deletions

View File

@@ -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<any>();
/** Emitted when there is an error. */
@Output()
@@ -92,6 +101,10 @@ export class TaskScreenCloudComponent implements OnInit {
@Output()
unclaimTask = new EventEmitter<any>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
@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) {

View File

@@ -27,11 +27,14 @@ export interface UserTaskCustomUi {
showCancelButton: boolean;
taskName: string;
taskId: string;
isNextTaskCheckboxChecked: boolean;
showNextTaskCheckbox: boolean;
cancelTask: EventEmitter<any>;
claimTask: EventEmitter<any>;
error: EventEmitter<any>;
switchToDisplayMode?: (newDisplayMode?: string) => void;
taskCompleted: EventEmitter<string>;
taskCompleted: EventEmitter<any>;
taskSaved: EventEmitter<string>;
unclaimTask: EventEmitter<any>;
nextTaskCheckboxCheckedChanged: EventEmitter<any>;
}

View File

@@ -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)"
/>
</ng-container>

View File

@@ -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 () => {

View File

@@ -150,7 +150,7 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
/** Emitted when the task is completed. */
@Output()
taskCompleted = new EventEmitter<string>();
taskCompleted = new EventEmitter<boolean>();
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 {