mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-33909 Ensure onProcessFinish event triggers when invoked from onFormLoaded event (#10867)
* AAE-33909 Ensure onProcessFinish event triggers when invoked from onFormLoaded event * clean code * fix unit tests * update outcomes buttons * update
This commit is contained in:
@@ -670,12 +670,36 @@ describe('FormCloudComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
const formValues: any[] = [];
|
||||
const formValues: TaskVariableCloud[] = [
|
||||
{
|
||||
name: 'var1',
|
||||
value: 'value1',
|
||||
id: 'var1',
|
||||
type: 'string',
|
||||
hasValue: () => true
|
||||
}
|
||||
];
|
||||
|
||||
const change = new SimpleChange(null, formValues, false);
|
||||
formComponent.data = formValues;
|
||||
formComponent.ngOnChanges({ data: change });
|
||||
});
|
||||
|
||||
it('should not change form if custom form values is empty array', () => {
|
||||
const formModel = new FormModel({
|
||||
id: 'id',
|
||||
taskId: 'task-id',
|
||||
fields: [{ id: 'field1' }, { id: 'field2' }]
|
||||
});
|
||||
formComponent.form = formModel;
|
||||
|
||||
const formValues: TaskVariableCloud[] = [];
|
||||
const change = new SimpleChange(null, formValues, false);
|
||||
formComponent.ngOnChanges({ data: change });
|
||||
|
||||
expect(formComponent.form).toEqual(formModel);
|
||||
});
|
||||
|
||||
it('should save task form and raise corresponding event', () => {
|
||||
spyOn(formCloudService, 'saveTaskForm').and.callFake(
|
||||
() =>
|
||||
|
@@ -242,13 +242,14 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
||||
return;
|
||||
}
|
||||
|
||||
const data = changes['data'];
|
||||
if (data?.currentValue) {
|
||||
const data = changes['data']?.currentValue;
|
||||
if (data?.length > 0) {
|
||||
this.refreshFormData();
|
||||
return;
|
||||
}
|
||||
|
||||
const formRepresentation = changes['form'];
|
||||
|
||||
if (formRepresentation?.currentValue) {
|
||||
this.form = formRepresentation.currentValue;
|
||||
this.onFormLoaded(this.form);
|
||||
|
@@ -17,13 +17,16 @@
|
||||
class="adf-process-input-container"
|
||||
floatLabel="always"
|
||||
*ngIf="showSelectProcessDropdown"
|
||||
data-automation-id="adf-select-cloud-process-dropdown">
|
||||
data-automation-id="adf-select-cloud-process-dropdown"
|
||||
>
|
||||
<mat-label class="adf-start-process-input-label">{{ 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.LABEL.TYPE' | translate }}</mat-label>
|
||||
<input
|
||||
matInput
|
||||
formControlName="processDefinition"
|
||||
[matAutocomplete]="auto"
|
||||
id="processDefinitionName">
|
||||
id="processDefinitionName"
|
||||
>
|
||||
|
||||
<div class="adf-process-input-autocomplete">
|
||||
<mat-autocomplete
|
||||
#auto="matAutocomplete"
|
||||
@@ -37,6 +40,7 @@
|
||||
{{ getProcessDefinitionValue(processDef) }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
|
||||
<button
|
||||
id="adf-select-process-dropdown"
|
||||
title="{{'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.SELECT_PROCESS_DROPDOWN' | translate}}"
|
||||
@@ -44,6 +48,7 @@
|
||||
(click)="displayDropdown($event)">
|
||||
<mat-icon>arrow_drop_down</mat-icon>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<mat-error
|
||||
*ngIf="processDefinition.hasError('required')"
|
||||
@@ -79,8 +84,8 @@
|
||||
[data]="resolvedValues"
|
||||
[formId]="processDefinitionCurrent.formKey"
|
||||
[displayModeConfigurations]="displayModeConfigurations"
|
||||
[showSaveButton]="false"
|
||||
[showCompleteButton]="false"
|
||||
[showSaveButton]="showSaveButton"
|
||||
[showCompleteButton]="showCompleteButton"
|
||||
[showRefreshButton]="false"
|
||||
[showValidationIcon]="false"
|
||||
[showTitle]="false"
|
||||
|
@@ -35,7 +35,8 @@ import {
|
||||
FormModel,
|
||||
InplaceFormInputComponent,
|
||||
LocalizedDatePipe,
|
||||
TranslationService
|
||||
TranslationService,
|
||||
isOutcomeButtonVisible
|
||||
} from '@alfresco/adf-core';
|
||||
import { AbstractControl, FormControl, FormGroup, ReactiveFormsModule, ValidatorFn, Validators } from '@angular/forms';
|
||||
import { MatAutocompleteModule, MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
||||
@@ -95,8 +96,6 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
||||
@ViewChild(MatAutocompleteTrigger)
|
||||
inputAutocomplete: MatAutocompleteTrigger;
|
||||
|
||||
@ViewChild('startForm') startForm: FormCloudComponent;
|
||||
|
||||
/** (required) Name of the app. */
|
||||
@Input()
|
||||
appName: string = '';
|
||||
@@ -207,6 +206,9 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
||||
private readonly hasVisibleOutcomesSubject = new BehaviorSubject<boolean>(false);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
|
||||
showSaveButton = false;
|
||||
showCompleteButton = false;
|
||||
|
||||
get isProcessFormValid(): boolean {
|
||||
if (this.hasForm && this.isFormCloudLoaded) {
|
||||
return (this.formCloud ? !Object.keys(this.formCloud.values).length : false) || this.formCloud?.isValid || this.isProcessStarting;
|
||||
@@ -256,6 +258,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
||||
.subscribe((processDefinitionName) => {
|
||||
this.selectProcessDefinitionByProcessDefinitionName(processDefinitionName);
|
||||
});
|
||||
|
||||
this.showStartProcessButton$ = combineLatest([this.displayStartSubject, this.hasVisibleOutcomesSubject]).pipe(
|
||||
map(([displayStart, hasVisibleOutcomes]) => (displayStart !== null ? displayStart === 'true' : !hasVisibleOutcomes))
|
||||
);
|
||||
@@ -284,9 +287,14 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
||||
this.isFormCloudLoaded = true;
|
||||
this.formCloud = form;
|
||||
|
||||
if (this.startForm) {
|
||||
this.hasVisibleOutcomesSubject.next(this.startForm.hasVisibleOutcomes);
|
||||
}
|
||||
const anyOutcomeVisible = form?.outcomes?.some((outcome) =>
|
||||
isOutcomeButtonVisible(outcome, {
|
||||
isFormReadOnly: form.readOnly,
|
||||
showCompleteButton: this.showCompleteButton,
|
||||
showSaveButton: this.showSaveButton
|
||||
})
|
||||
);
|
||||
this.hasVisibleOutcomesSubject.next(anyOutcomeVisible);
|
||||
}
|
||||
|
||||
private getMaxNameLength(): number {
|
||||
|
Reference in New Issue
Block a user