mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ACA-3229] - fixed error on start process cloud when all the value a… (#5660)
* [ACA-3229] - fixed error on start process cloud when all the value are selected by default * Update start-process-cloud.component.ts Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
This commit is contained in:
parent
1b530e3236
commit
1430314815
@ -33,6 +33,7 @@ import { fakeProcessDefinitions, fakeStartForm, fakeStartFormNotValid,
|
||||
fakeProcessInstance, fakeNoNameProcessDefinitions,
|
||||
fakeSingleProcessDefinition, fakeCreatedProcessInstance } from '../mock/start-process.component.mock';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
||||
|
||||
describe('StartProcessCloudComponent', () => {
|
||||
|
||||
@ -99,6 +100,7 @@ describe('StartProcessCloudComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
|
||||
getDefinitionsSpy = spyOn(processService, 'getProcessDefinitions').and.returnValue(of(fakeProcessDefinitions));
|
||||
spyOn(processService, 'updateProcess').and.returnValue(of());
|
||||
startProcessSpy = spyOn(processService, 'startCreatedProcess').and.returnValue(of(fakeProcessInstance));
|
||||
createProcessSpy = spyOn(processService, 'createProcess').and.returnValue(of(fakeCreatedProcessInstance));
|
||||
});
|
||||
@ -128,7 +130,8 @@ describe('StartProcessCloudComponent', () => {
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(false);
|
||||
expect(component.isProcessFormValid()).toBe(true);
|
||||
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', component.processPayloadCloud);
|
||||
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', new ProcessPayloadCloud({name: 'OLE',
|
||||
processDefinitionKey: fakeProcessDefinitions[1].key}));
|
||||
expect(component.currentCreatedProcess.status).toBe('CREATED');
|
||||
expect(component.currentCreatedProcess.startDate).toBeNull();
|
||||
}));
|
||||
@ -297,7 +300,8 @@ describe('StartProcessCloudComponent', () => {
|
||||
expect(startBtn.disabled).toBe(false);
|
||||
expect(component.formCloud.isValid).toBe(true);
|
||||
expect(component.isProcessFormValid()).toBe(true);
|
||||
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', component.processPayloadCloud);
|
||||
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', new ProcessPayloadCloud({name: 'testFormWithProcess',
|
||||
processDefinitionKey: fakeProcessDefinitions[1].key}));
|
||||
expect(component.currentCreatedProcess.status).toBe('CREATED');
|
||||
expect(component.currentCreatedProcess.startDate).toBeNull();
|
||||
}));
|
||||
|
@ -28,7 +28,7 @@ import { MatAutocompleteTrigger } from '@angular/material';
|
||||
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
||||
import { debounceTime, takeUntil, switchMap, filter, distinctUntilChanged } from 'rxjs/operators';
|
||||
import { ProcessDefinitionCloud } from '../models/process-definition-cloud.model';
|
||||
import { Subject, Observable } from 'rxjs';
|
||||
import { Subject, Observable, concat } from 'rxjs';
|
||||
import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model';
|
||||
|
||||
@Component({
|
||||
@ -167,8 +167,11 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
||||
}
|
||||
|
||||
private generateProcessInstance(): Observable <ProcessInstanceCloud> {
|
||||
this.buildProcessCloudPayload();
|
||||
return this.startProcessCloudService.createProcess(this.appName, this.processPayloadCloud);
|
||||
const createPayload: ProcessPayloadCloud = new ProcessPayloadCloud({
|
||||
name: this.processInstanceName.value,
|
||||
processDefinitionKey: this.processPayloadCloud.processDefinitionKey
|
||||
});
|
||||
return this.startProcessCloudService.createProcess(this.appName, createPayload);
|
||||
}
|
||||
|
||||
private selectProcessDefinitionByProcesDefinitionName(processDefinitionName: string): void {
|
||||
@ -271,10 +274,11 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
||||
|
||||
startProcess() {
|
||||
this.isLoading = true;
|
||||
|
||||
this.buildProcessCloudPayload();
|
||||
|
||||
this.startProcessCloudService.startCreatedProcess(this.appName, this.currentCreatedProcess.id).subscribe(
|
||||
concat(
|
||||
this.startProcessCloudService.updateProcess(this.appName, this.currentCreatedProcess.id, this.processPayloadCloud),
|
||||
this.startProcessCloudService.startCreatedProcess(this.appName, this.currentCreatedProcess.id)
|
||||
).subscribe(
|
||||
(res) => {
|
||||
this.success.emit(res);
|
||||
this.isLoading = false;
|
||||
|
@ -63,6 +63,7 @@ export class StartProcessCloudService extends BaseCloudService {
|
||||
*/
|
||||
createProcess(appName: string, payload: ProcessPayloadCloud): Observable<ProcessInstanceCloud> {
|
||||
const url = `${this.getBasePath(appName)}/rb/v1/process-instances/create`;
|
||||
payload.payloadType = 'StartProcessPayload';
|
||||
|
||||
return this.post(url, payload).pipe(
|
||||
map((result: any) => result.entry),
|
||||
@ -92,9 +93,26 @@ export class StartProcessCloudService extends BaseCloudService {
|
||||
*/
|
||||
startProcess(appName: string, payload: ProcessPayloadCloud): Observable<ProcessInstanceCloud> {
|
||||
const url = `${this.getBasePath(appName)}/rb/v1/process-instances`;
|
||||
payload.payloadType = 'StartProcessPayload';
|
||||
|
||||
return this.post(url, payload).pipe(
|
||||
map(processInstance => new ProcessInstanceCloud(processInstance))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing process instance
|
||||
* @param appName name of the Application
|
||||
* @param processInstanceId process instance to update
|
||||
* @param payload Details of the process (definition key, name, variables, etc)
|
||||
* @returns Details of the process instance just started
|
||||
*/
|
||||
updateProcess(appName: string, processInstanceId: string, payload: ProcessPayloadCloud): Observable<ProcessInstanceCloud> {
|
||||
const url = `${this.getBasePath(appName)}/rb/v1/process-instances/${processInstanceId}`;
|
||||
payload.payloadType = 'UpdateProcessPayload';
|
||||
|
||||
return this.put(url, payload).pipe(
|
||||
map(processInstance => new ProcessInstanceCloud(processInstance))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user