AAE-33090 Open Next Task Checkbox (#10757)

* [AAE-33090] Add optional checkbox for 'open next task' feature

* [AAE-33090] move translation to LABEL property

* [33090] add unit tests

* add tests for checkbox value

* [AAE-33090] remove some comments

* [AAE-33090] update documentation

* AAE-33090 kind of a typo

* AAE-33090 remove all comments
This commit is contained in:
Jonas Wollweber
2025-04-09 10:14:06 +02:00
committed by GitHub
parent f6c446498a
commit 659805ab20
17 changed files with 286 additions and 62 deletions

View File

@@ -74,6 +74,8 @@
<adf-form-renderer [formDefinition]="form" [readOnly]="readOnly" />
</mat-card-content>
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions" align="end">
<mat-checkbox id="adf-form-open-next-task" *ngIf="showNextTaskCheckbox" [checked]="isNextTaskCheckboxChecked" (change)="onNextTaskCheckboxCheckedChanged($event)">{{'ADF_CLOUD_TASK_FORM.OPEN_NEXT_TASK.LABEL' | translate}}</mat-checkbox>
<span class="adf-card-actions-spacer"></span>
<ng-content select="adf-cloud-form-custom-outcomes" />
<ng-container *ngFor="let outcome of form.outcomes">
<button

View File

@@ -18,6 +18,10 @@
flex-direction: column;
display: flex;
}
.adf-card-actions-spacer {
flex: 1 1 auto;
}
}
&-fullscreen-container {

View File

@@ -67,6 +67,7 @@ import { ProcessServiceCloudTestingModule } from '../../testing/process-service-
import { TaskVariableCloud } from '../models/task-variable-cloud.model';
import { ProcessServicesCloudModule } from '../../process-services-cloud.module';
import { FormFieldValidator } from '../../../../../core/src/public-api';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
const mockOauth2Auth: any = {
oauth2Auth: {
@@ -1191,6 +1192,64 @@ describe('FormCloudComponent', () => {
expect(form.fieldValidators.length).toBe(10);
});
it('should allow controlling [open next task] checkbox visibility', () => {
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
const isCheckboxShown = () => {
const checkbox = fixture.debugElement.query(By.css('#adf-form-open-next-task'));
return !!checkbox;
};
fixture.detectChanges();
expect(isCheckboxShown()).toBeFalse();
formComponent.showNextTaskCheckbox = true;
fixture.detectChanges();
expect(isCheckboxShown()).toBeTrue();
formComponent.showNextTaskCheckbox = false;
fixture.detectChanges();
expect(isCheckboxShown()).toBeFalse();
});
it('should allow controlling [open next task] checkbox value', async () => {
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
formComponent.showNextTaskCheckbox = true;
fixture.detectChanges();
const isCheckboxChecked = async () => {
const checkbox = await documentRootLoader.getHarness(MatCheckboxHarness.with({ selector: '#adf-form-open-next-task' }));
return checkbox.isChecked();
};
expect(await isCheckboxChecked()).toBeFalse();
formComponent.isNextTaskCheckboxChecked = true;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeTrue();
formComponent.isNextTaskCheckboxChecked = false;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeFalse();
});
it('should call onNextTaskCheckboxCheckedChanged when the checkbox is checked', async () => {
// Add fields to make sure the components are shown which contain the the checkbox
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
formComponent.showNextTaskCheckbox = true;
fixture.detectChanges();
const checkbox = await documentRootLoader.getHarnessOrNull(MatCheckboxHarness);
spyOn(formComponent.nextTaskCheckboxCheckedChanged, 'emit');
await checkbox.check();
expect(formComponent.nextTaskCheckboxCheckedChanged.emit).toHaveBeenCalled();
});
describe('form validations', () => {
it('should be able to set visibility conditions for Attach File widget', async () => {
spyOn(formCloudService, 'getForm').and.returnValue(of(conditionalUploadWidgetsMock));

View File

@@ -67,6 +67,7 @@ import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { A11yModule } from '@angular/cdk/a11y';
import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox';
export const FORM_CLOUD_FIELD_VALIDATORS_TOKEN = new InjectionToken<FormFieldValidator[]>('FORM_CLOUD_FIELD_VALIDATORS_TOKEN');
@@ -83,7 +84,8 @@ export const FORM_CLOUD_FIELD_VALIDATORS_TOKEN = new InjectionToken<FormFieldVal
MatIconModule,
ToolbarDividerComponent,
ToolbarComponent,
A11yModule
A11yModule,
MatCheckboxModule
],
providers: [FormCloudSpinnerService],
templateUrl: './form-cloud.component.html',
@@ -114,12 +116,18 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
@Input()
data: TaskVariableCloud[];
/**
* The available display configurations for the form
*/
/** The available display configurations for the form */
@Input()
displayModeConfigurations: FormCloudDisplayModeConfiguration[];
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Emitted when the form is submitted with the `Save` or custom outcomes. */
@Output()
formSaved = new EventEmitter<FormModel>();
@@ -148,6 +156,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
@Output()
displayModeOff = new EventEmitter<FormCloudDisplayModeConfiguration>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
protected subscriptions: Subscription[] = [];
nodeId: string;
formCloudRepresentationJSON: any;
@@ -510,4 +522,8 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
this.fieldValidators = [...this.fieldValidators, ...injectedFieldValidators];
}
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
}

View File

@@ -379,7 +379,8 @@
"ERROR": {
"INVALID_DESTINATION_FOLDER_PATH": "Invalid destination folder path",
"DESTINATION_FOLDER_PATH_ERROR": "The destination path is incorrect or does not exist, rollback to -my- location"
}
},
"OPEN_NEXT_TASK": {"LABEL": "Open next task"}
},
"ADF_CLOUD_FORM_COMPONENT": {
"RETRIEVE_METADATA": "Autofill Form"

View File

@@ -84,9 +84,13 @@
[showRefreshButton]="false"
[showValidationIcon]="false"
[showTitle]="false"
[showNextTaskCheckbox]="showNextTaskCheckbox"
[isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked"
(formContentClicked)="onFormContentClicked($event)"
(formLoaded)="onFormLoaded($event)"
(executeOutcome)="onCustomOutcomeClicked($event.outcome.name)">
(executeOutcome)="onCustomOutcomeClicked($event.outcome.name)"
(nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)"
>
<adf-cloud-form-custom-outcomes>
<ng-template [ngTemplateOutlet]="taskFormCloudButtons" />
</adf-cloud-form-custom-outcomes>

View File

@@ -53,6 +53,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatOptionModule } from '@angular/material/core';
import { FormCloudComponent } from '../../../form/components/form-cloud.component';
import { FormCustomOutcomesComponent } from '../../../form/components/form-cloud-custom-outcomes.component';
import { MatCheckboxChange } from '@angular/material/checkbox';
const MAX_NAME_LENGTH: number = 255;
const PROCESS_DEFINITION_DEBOUNCE: number = 300;
@@ -131,6 +132,14 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
@Input()
displayModeConfigurations: FormCloudDisplayModeConfiguration[];
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Emitted when the process is successfully started. */
@Output()
success = new EventEmitter<ProcessInstanceCloud>();
@@ -151,6 +160,10 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
@Output()
processDefinitionSelection: EventEmitter<ProcessDefinitionCloud> = new EventEmitter<ProcessDefinitionCloud>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
processDefinitionList: ProcessDefinitionCloud[] = [];
processDefinitionCurrent?: ProcessDefinitionCloud;
errorMessageId: string = '';
@@ -541,4 +554,8 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
}
return processName;
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
}

View File

@@ -12,6 +12,8 @@
[showCompleteButton]="canCompleteTask()"
[showSaveButton]="canCompleteTask()"
[displayModeConfigurations]="displayModeConfigurations"
[showNextTaskCheckbox]="showNextTaskCheckbox"
[isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked"
(formSaved)="onFormSaved($event)"
(formCompleted)="onFormCompleted($event)"
(formError)="onError($event)"
@@ -20,6 +22,7 @@
(executeOutcome)="onFormExecuteOutcome($event)"
(displayModeOn)="onDisplayModeOn($event)"
(displayModeOff)="onDisplayModeOff($event)"
(nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)"
>
<adf-cloud-form-custom-outcomes>
<adf-cloud-user-task-cloud-buttons

View File

@@ -27,6 +27,7 @@ import { TaskDetailsCloudModel } from '../../../models/task-details-cloud.model'
import { CommonModule } from '@angular/common';
import { UserTaskCloudButtonsComponent } from '../user-task-cloud-buttons/user-task-cloud-buttons.component';
import { FormCustomOutcomesComponent } from '../../../../form/components/form-cloud-custom-outcomes.component';
import { MatCheckboxChange } from '@angular/material/checkbox';
@Component({
selector: 'adf-cloud-task-form',
@@ -87,6 +88,14 @@ export class TaskFormCloudComponent {
@Input()
taskDetails: TaskDetailsCloudModel;
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Emitted when the form is saved. */
@Output()
formSaved = new EventEmitter<FormModel>();
@@ -134,6 +143,10 @@ export class TaskFormCloudComponent {
@Output()
displayModeOff = new EventEmitter<FormCloudDisplayModeConfiguration>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
@ViewChild('adfCloudForm', { static: false })
adfCloudForm: FormCloudComponent;
@@ -225,4 +238,8 @@ export class TaskFormCloudComponent {
onDisplayModeOff(displayModeConfiguration: FormCloudDisplayModeConfiguration) {
this.displayModeOff.emit(displayModeConfiguration);
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
}

View File

@@ -12,6 +12,8 @@
[showTitle]="showTitle"
[taskId]="taskId"
[taskDetails]="taskDetails"
[showNextTaskCheckbox]="showNextTaskCheckbox"
[isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked"
(cancelClick)="onCancelForm()"
(executeOutcome)="onExecuteOutcome($event)"
(error)="onError($event)"
@@ -20,6 +22,7 @@
(taskCompleted)="onCompleteTaskForm()"
(taskClaimed)="onClaimTask()"
(taskUnclaimed)="onTaskUnclaimed()"
(nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)"
/>
</ng-container>
@@ -63,6 +66,8 @@
[subtitle]="'ADF_CLOUD_TASK_FORM.EMPTY_FORM.SUBTITLE'" />
</mat-card-content>
<mat-card-actions class="adf-task-form-actions" align="end">
<mat-checkbox id="adf-form-open-next-task" *ngIf="showNextTaskCheckbox" [checked]="isNextTaskCheckboxChecked" (change)="onNextTaskCheckboxCheckedChanged($event)">{{'ADF_CLOUD_TASK_FORM.OPEN_NEXT_TASK.LABEL' | translate}}</mat-checkbox>
<span class="adf-card-actions-spacer"></span>
<ng-template [ngTemplateOutlet]="taskFormCloudButtons" />
<button
*ngIf="canCompleteTask()"

View File

@@ -4,6 +4,10 @@
> div {
height: 100%;
}
.adf-card-actions-spacer {
flex: 1 1 auto;
}
}
.adf-user-task-cloud-spinner {

View File

@@ -36,6 +36,8 @@ import { ProcessServiceCloudTestingModule } from 'lib/process-services-cloud/src
import { of, throwError } from 'rxjs';
import { IdentityUserService } from '../../../../people/services/identity-user.service';
import { UserTaskCloudComponent } from './user-task-cloud.component';
import { By } from '@angular/platform-browser';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
const taskDetails: TaskDetailsCloudModel = {
appName: 'simple-app',
@@ -476,4 +478,61 @@ describe('UserTaskCloudComponent', () => {
const noFormTemplateTitleText = await matCard.getTitleText();
expect(noFormTemplateTitleText).toBe('');
});
it('should allow controlling [open next task] checkbox visibility', () => {
taskDetails.formKey = 'form';
component.getTaskType();
const isCheckboxShown = () => {
const checkbox = fixture.debugElement.query(By.css('#adf-form-open-next-task'));
return !!checkbox;
};
fixture.detectChanges();
expect(isCheckboxShown()).toBeFalse();
component.showNextTaskCheckbox = true;
fixture.detectChanges();
expect(isCheckboxShown()).toBeTrue();
component.showNextTaskCheckbox = false;
fixture.detectChanges();
expect(isCheckboxShown()).toBeFalse();
});
it('should allow controlling [open next task] checkbox value', async () => {
taskDetails.formKey = 'form';
component.getTaskType();
component.showNextTaskCheckbox = true;
const isCheckboxChecked = async () => {
const checkbox = await loader.getHarness(MatCheckboxHarness.with({ selector: '#adf-form-open-next-task' }));
return checkbox.isChecked();
};
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeFalse();
component.isNextTaskCheckboxChecked = true;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeTrue();
component.isNextTaskCheckboxChecked = false;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeFalse();
});
it('should call onNextTaskCheckboxCheckedChanged when the checkbox is checked', async () => {
taskDetails.formKey = 'form';
component.getTaskType();
component.showNextTaskCheckbox = true;
fixture.detectChanges();
const checkbox = await loader.getHarnessOrNull(MatCheckboxHarness);
spyOn(component.nextTaskCheckboxCheckedChanged, 'emit');
await checkbox.check();
expect(component.nextTaskCheckboxCheckedChanged.emit).toHaveBeenCalled();
});
});

View File

@@ -31,6 +31,7 @@ import { MatCardModule } from '@angular/material/card';
import { TaskScreenCloudComponent } from '../../../../screen/components/screen-cloud/screen-cloud.component';
import { CompleteTaskDirective } from './complete-task/complete-task.directive';
import { catchError, EMPTY, forkJoin } from 'rxjs';
import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox';
const TaskTypes = {
Form: 'form',
@@ -53,7 +54,8 @@ type TaskTypesType = (typeof TaskTypes)[keyof typeof TaskTypes];
EmptyContentComponent,
TaskScreenCloudComponent,
TaskFormCloudComponent,
CompleteTaskDirective
CompleteTaskDirective,
MatCheckboxModule
],
templateUrl: './user-task-cloud.component.html',
styleUrls: ['./user-task-cloud.component.scss']
@@ -85,6 +87,14 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
@Input()
showCompleteButton = true;
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Toggle rendering of the form title. */
@Input()
showTitle: boolean = true;
@@ -105,6 +115,10 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
@Output()
error = new EventEmitter<any>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
/**
* Emitted when any outcome is executed. Default behaviour can be prevented
* via `event.preventDefault()`.
@@ -182,15 +196,19 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
}
getTaskType(): void {
if (this.taskDetails && !!this.taskDetails.formKey && this.taskDetails.formKey.includes(this.taskTypeEnum.Form)) {
this.taskType = this.taskTypeEnum.Form;
} else if (this.taskDetails && !!this.taskDetails.formKey && this.taskDetails.formKey.includes(this.taskTypeEnum.Screen)) {
this.taskType = this.taskTypeEnum.Screen;
const screenId = this.taskDetails.formKey.replace(this.taskTypeEnum.Screen + '-', '');
this.screenId = screenId;
} else {
this.taskType = this.taskTypeEnum.None;
if (this.taskDetails && !!this.taskDetails.formKey) {
if (this.taskDetails.formKey.includes(this.taskTypeEnum.Form)) {
this.taskType = this.taskTypeEnum.Form;
return;
} else if (this.taskDetails.formKey.includes(this.taskTypeEnum.Screen)) {
this.taskType = this.taskTypeEnum.Screen;
const screenId = this.taskDetails.formKey.replace(this.taskTypeEnum.Screen + '-', '');
this.screenId = screenId;
return;
}
}
this.taskType = this.taskTypeEnum.None;
}
hasCandidateUsers(): boolean {
@@ -250,6 +268,10 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
this.taskUnclaimed.emit(this.taskId);
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
private loadTask(): void {
this.loading = true;
const tasks$ = this.taskCloudService.getTaskById(this.appName, this.taskId);