Skip to content

Commit

Permalink
AAE-21573 Add display mode support for porcess start event form (#10273)
Browse files Browse the repository at this point in the history
  • Loading branch information
BSekula authored Oct 7, 2024
1 parent 0e085bc commit 35f24fd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
[appVersion]="processDefinitionCurrent.appVersion"
[data]="resolvedValues"
[formId]="processDefinitionCurrent.formKey"
[displayModeConfigurations]="displayModeConfigurations"
[fieldValidators]="fieldValidators"
[showSaveButton]="false"
[showCompleteButton]="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { FormCloudDisplayMode } from '../../../services/form-fields.interfaces';

describe('StartProcessCloudComponent', () => {
let loader: HarnessLoader;
Expand Down Expand Up @@ -348,6 +349,44 @@ describe('StartProcessCloudComponent', () => {
expect(startBtn.disabled).toBe(false);
});

it('should be able to start a process with form full display mode', async () => {
component.displayModeConfigurations = [
{
displayMode: FormCloudDisplayMode.fullScreen,
options: {
onDisplayModeOn: () => {},
onDisplayModeOff: () => {},
onCompleteTask: () => {},
onSaveTask: () => {},
fullscreen: true,
displayToolbar: true,
displayCloseButton: true,
trapFocus: true
}
}
];

const fakeStartFormClone = structuredClone(fakeStartForm);

(fakeStartFormClone.formRepresentation as any).displayMode = FormCloudDisplayMode.fullScreen;

formDefinitionSpy.and.returnValue(of(fakeStartFormClone));
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition('processwithform')));
typeValueInto('[data-automation-id="adf-inplace-input"]', 'My new process with form');
typeValueInto('#processDefinitionName', 'processwithform');
fixture.detectChanges();
await fixture.whenStable();

fixture.detectChanges();
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
expect(firstNameEl).toBeDefined();
const lastNameEl = fixture.nativeElement.querySelector('#lastName');
expect(lastNameEl).toBeDefined();
const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(component.formCloud.isValid).toBe(true);
expect(startBtn.disabled).toBe(false);
});

it('should NOT be able to start a process with a form NOT valid', async () => {
formDefinitionSpy.and.returnValue(of(fakeStartFormNotValid));
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition('processwithform')));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { forkJoin, of, Subject } from 'rxjs';
import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud.model';
import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model';
import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
import { FormCloudDisplayModeConfiguration } from '../../../services/form-fields.interfaces';

const MAX_NAME_LENGTH: number = 255;
const PROCESS_DEFINITION_DEBOUNCE: number = 300;
Expand Down Expand Up @@ -96,6 +97,13 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
@Input()
showCancelButton: boolean = true;

/**
* The available display configurations for the form.
* (start process event can have assigned form)
*/
@Input()
displayModeConfigurations: FormCloudDisplayModeConfiguration[];

/** Emitted when the process is successfully started. */
@Output()
success = new EventEmitter<ProcessInstanceCloud>();
Expand Down

0 comments on commit 35f24fd

Please sign in to comment.