mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-25409 Fix custom outcome button not starting a process if used in start process form (#10232)
* AAE-25409 Fix custom outcome button not starting a process if used in start process form * AAE-25409 comment adjustments * AAE-25409 remove hardcoded process version * AAE-25409 modify start process cloud for the solution * AAE-25409 add unit test
This commit is contained in:
@@ -84,7 +84,8 @@
|
|||||||
[showValidationIcon]="false"
|
[showValidationIcon]="false"
|
||||||
[showTitle]="false"
|
[showTitle]="false"
|
||||||
(formContentClicked)="onFormContentClicked($event)"
|
(formContentClicked)="onFormContentClicked($event)"
|
||||||
(formLoaded)="onFormLoaded($event)">
|
(formLoaded)="onFormLoaded($event)"
|
||||||
|
(executeOutcome)="onCustomOutcomeClicked($event.outcome.name)">
|
||||||
<adf-cloud-form-custom-outcomes>
|
<adf-cloud-form-custom-outcomes>
|
||||||
<ng-template [ngTemplateOutlet]="taskFormCloudButtons">
|
<ng-template [ngTemplateOutlet]="taskFormCloudButtons">
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
@@ -780,6 +780,36 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
expect(startProcessSpy).toHaveBeenCalledWith(component.appName, payload);
|
expect(startProcessSpy).toHaveBeenCalledWith(component.appName, payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call service with the correct parameters when formCloud is defined and custom outcome is clicked', async () => {
|
||||||
|
formDefinitionSpy.and.returnValue(of(fakeFormModelJson));
|
||||||
|
component.ngOnChanges({ appName: firstChange });
|
||||||
|
component.processForm.controls['processInstanceName'].setValue('My Process 1');
|
||||||
|
component.appName = 'test app name';
|
||||||
|
component.formCloud = new FormModel(JSON.stringify(fakeFormModelJson));
|
||||||
|
component.formCloud.values = { dropdown: { id: '1', name: 'label 2' } };
|
||||||
|
component.processDefinitionCurrent = fakeProcessDefinitions[2];
|
||||||
|
component.processPayloadCloud.processDefinitionKey = fakeProcessDefinitions[2].key;
|
||||||
|
|
||||||
|
const payload: ProcessWithFormPayloadCloud = new ProcessWithFormPayloadCloud({
|
||||||
|
processName: component.processInstanceName.value,
|
||||||
|
processDefinitionKey: fakeProcessDefinitions[2].key,
|
||||||
|
variables: {},
|
||||||
|
values: component.formCloud.values,
|
||||||
|
outcome: 'custom_outcome'
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.onCustomOutcomeClicked('custom_outcome');
|
||||||
|
|
||||||
|
expect(startProcessWithFormSpy).toHaveBeenCalledWith(
|
||||||
|
component.appName,
|
||||||
|
fakeProcessDefinitions[2].formKey,
|
||||||
|
fakeProcessDefinitions[2].version,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should call service with the correct parameters when variables are undefined and formCloud is defined', async () => {
|
it('should call service with the correct parameters when variables are undefined and formCloud is defined', async () => {
|
||||||
getDefinitionsSpy.and.returnValue(of([fakeProcessDefinitions[2]]));
|
getDefinitionsSpy.and.returnValue(of([fakeProcessDefinitions[2]]));
|
||||||
formDefinitionSpy.and.returnValue(of(fakeStartForm));
|
formDefinitionSpy.and.returnValue(of(fakeStartForm));
|
||||||
|
@@ -123,6 +123,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
|||||||
filteredProcesses: ProcessDefinitionCloud[] = [];
|
filteredProcesses: ProcessDefinitionCloud[] = [];
|
||||||
staticMappings: TaskVariableCloud[] = [];
|
staticMappings: TaskVariableCloud[] = [];
|
||||||
resolvedValues?: TaskVariableCloud[];
|
resolvedValues?: TaskVariableCloud[];
|
||||||
|
customOutcome: string;
|
||||||
|
|
||||||
protected onDestroy$ = new Subject<boolean>();
|
protected onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
@@ -366,6 +367,11 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCustomOutcomeClicked(outcome: string) {
|
||||||
|
this.customOutcome = outcome;
|
||||||
|
this.startProcess();
|
||||||
|
}
|
||||||
|
|
||||||
startProcess() {
|
startProcess() {
|
||||||
this.isProcessStarting = true;
|
this.isProcessStarting = true;
|
||||||
|
|
||||||
@@ -378,7 +384,8 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
|||||||
processName: this.processInstanceName.value,
|
processName: this.processInstanceName.value,
|
||||||
processDefinitionKey: this.processPayloadCloud.processDefinitionKey,
|
processDefinitionKey: this.processPayloadCloud.processDefinitionKey,
|
||||||
variables: this.variables ?? {},
|
variables: this.variables ?? {},
|
||||||
values: this.formCloud.values
|
values: this.formCloud.values,
|
||||||
|
outcome: this.customOutcome
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
: this.startProcessCloudService.startProcess(
|
: this.startProcessCloudService.startProcess(
|
||||||
|
@@ -20,11 +20,13 @@ export class ProcessWithFormPayloadCloud {
|
|||||||
processDefinitionKey: string;
|
processDefinitionKey: string;
|
||||||
variables: any;
|
variables: any;
|
||||||
values: any;
|
values: any;
|
||||||
|
outcome?: string;
|
||||||
|
|
||||||
constructor(obj: ProcessWithFormPayloadCloud) {
|
constructor(obj: ProcessWithFormPayloadCloud) {
|
||||||
this.processName = obj.processName;
|
this.processName = obj.processName;
|
||||||
this.processDefinitionKey = obj.processDefinitionKey;
|
this.processDefinitionKey = obj.processDefinitionKey;
|
||||||
this.variables = obj.variables;
|
this.variables = obj.variables;
|
||||||
this.values = obj.values;
|
this.values = obj.values;
|
||||||
|
this.outcome = obj.outcome;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user