mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
activiti-start-process should accept list of process variable in input (#1880)
This commit is contained in:
committed by
Eugenio Romano
parent
075ee8a538
commit
59021ae9d2
@@ -267,13 +267,13 @@ The AccordionComponent is exposed by the alfresco-core.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Start Process Button component
|
### Start Process component
|
||||||
|
|
||||||
Displays a button which in turn displays a dialog when clicked, allowing the user
|
Displays a button which in turn displays a dialog when clicked, allowing the user
|
||||||
to specify some basic details needed to start a new process instance.
|
to specify some basic details needed to start a new process instance.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<activiti-start-process-instance></activiti-start-process-instance>
|
<activiti-start-process appId="YOUR_APP_ID" ></activiti-start-process>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
@@ -281,18 +281,24 @@ to specify some basic details needed to start a new process instance.
|
|||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `appId` | Limit the list of processes which can be started to those contained in the specified app |
|
| `appId` | (required): Limit the list of processes which can be started to those contained in the specified app |
|
||||||
|
| `variables` | Variables in input to the process [RestVariable]**](https://github.com/Alfresco/alfresco-js-api/tree/master/src/alfresco-activiti-rest-api/docs/RestVariable.md)|
|
||||||
|
|
||||||
|
|
||||||
#### Events
|
#### Events
|
||||||
|
|
||||||
No events are emitted by this component
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `start` | The event is emitted when the process start |
|
||||||
|
| `error` | The event is emitted when the start process fail |
|
||||||
|
|
||||||
|
|
||||||
### Process Details component
|
### Process Details component
|
||||||
|
|
||||||
This component displays detailed information on a specified process instance
|
This component displays detailed information on a specified process instance
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<activiti-process-instance-details processInstanceId="123"></activiti-process-instance-details>
|
<activiti-process-instance-details processInstanceId="YOUR_PROCESS_INSTANCE_ID"></activiti-process-instance-details>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
@@ -337,7 +343,7 @@ This is a sub-component of the process details component, which renders some gen
|
|||||||
Lists both the active and completed tasks associated with a particular process instance
|
Lists both the active and completed tasks associated with a particular process instance
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<activiti-process-instance-tasks processInstanceId="123" showRefreshButton="true"></activiti-process-instance-tasks>
|
<activiti-process-instance-tasks processInstanceId="YOUR_PROCESS_INSTANCE_ID" showRefreshButton="true"></activiti-process-instance-tasks>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
@@ -359,7 +365,7 @@ Lists both the active and completed tasks associated with a particular process i
|
|||||||
Displays comments associated with a particular process instances and allows the user to add new comments
|
Displays comments associated with a particular process instances and allows the user to add new comments
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<activiti-process-instance-comments processInstanceId="123"></activiti-process-instance-comments>
|
<activiti-process-instance-comments processInstanceId="YOUR_PROCESS_INSTANCE_ID"></activiti-process-instance-comments>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
|
@@ -26,6 +26,7 @@ import { TranslationMock } from './../assets/translation.service.mock';
|
|||||||
import { newProcess, fakeProcessDefs, fakeProcessDefWithForm, taskFormMock } from './../assets/activiti-start-process.component.mock';
|
import { newProcess, fakeProcessDefs, fakeProcessDefWithForm, taskFormMock } from './../assets/activiti-start-process.component.mock';
|
||||||
import { ActivitiStartProcessInstance } from './activiti-start-process.component';
|
import { ActivitiStartProcessInstance } from './activiti-start-process.component';
|
||||||
import { ActivitiProcessService } from '../services/activiti-process.service';
|
import { ActivitiProcessService } from '../services/activiti-process.service';
|
||||||
|
import { RestVariable } from 'alfresco-js-api';
|
||||||
|
|
||||||
describe('ActivitiStartProcessInstance', () => {
|
describe('ActivitiStartProcessInstance', () => {
|
||||||
|
|
||||||
@@ -201,7 +202,24 @@ describe('ActivitiStartProcessInstance', () => {
|
|||||||
component.onProcessDefChange('my:process1');
|
component.onProcessDefChange('my:process1');
|
||||||
component.startProcess();
|
component.startProcess();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined, undefined);
|
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined, undefined, undefined);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should call service to start process with the variables setted', async(() => {
|
||||||
|
let inputProcessVariable = [];
|
||||||
|
|
||||||
|
let variable: any = {};
|
||||||
|
variable.name = 'nodeId';
|
||||||
|
variable.value ='id';
|
||||||
|
|
||||||
|
inputProcessVariable.push(variable);
|
||||||
|
|
||||||
|
component.variables = inputProcessVariable;
|
||||||
|
component.onProcessDefChange('my:process1');
|
||||||
|
component.startProcess();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined, undefined, inputProcessVariable);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -214,8 +232,8 @@ describe('ActivitiStartProcessInstance', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should throw start event error when process cannot be started', async(() => {
|
it('should throw error event when process cannot be started', async(() => {
|
||||||
let errorSpy = spyOn(component.start, 'error');
|
let errorSpy = spyOn(component.error, 'error');
|
||||||
let error = { message: 'My error' };
|
let error = { message: 'My error' };
|
||||||
startProcessSpy = startProcessSpy.and.returnValue(Observable.throw(error));
|
startProcessSpy = startProcessSpy.and.returnValue(Observable.throw(error));
|
||||||
component.onProcessDefChange('my:process1');
|
component.onProcessDefChange('my:process1');
|
||||||
|
@@ -21,6 +21,7 @@ import { ActivitiStartForm } from 'ng2-activiti-form';
|
|||||||
import { ProcessInstance } from './../models/process-instance.model';
|
import { ProcessInstance } from './../models/process-instance.model';
|
||||||
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
|
||||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||||
|
import { RestVariable } from 'alfresco-js-api';
|
||||||
|
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
declare let dialogPolyfill: any;
|
declare let dialogPolyfill: any;
|
||||||
@@ -36,11 +37,14 @@ export class ActivitiStartProcessInstance implements OnChanges {
|
|||||||
appId: string;
|
appId: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showStartButton: boolean = true;
|
variables: RestVariable;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
start: EventEmitter<ProcessInstance> = new EventEmitter<ProcessInstance>();
|
start: EventEmitter<ProcessInstance> = new EventEmitter<ProcessInstance>();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
error: EventEmitter<ProcessInstance> = new EventEmitter<ProcessInstance>();
|
||||||
|
|
||||||
@ViewChild(ActivitiStartForm)
|
@ViewChild(ActivitiStartForm)
|
||||||
startForm: ActivitiStartForm;
|
startForm: ActivitiStartForm;
|
||||||
|
|
||||||
@@ -85,14 +89,14 @@ export class ActivitiStartProcessInstance implements OnChanges {
|
|||||||
if (this.currentProcessDef.id && this.name) {
|
if (this.currentProcessDef.id && this.name) {
|
||||||
this.resetErrorMessage();
|
this.resetErrorMessage();
|
||||||
let formValues = this.startForm ? this.startForm.form.values : undefined;
|
let formValues = this.startForm ? this.startForm.form.values : undefined;
|
||||||
this.activitiProcess.startProcess(this.currentProcessDef.id, this.name, outcome, formValues).subscribe(
|
this.activitiProcess.startProcess(this.currentProcessDef.id, this.name, outcome, formValues, this.variables).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
this.name = '';
|
this.name = '';
|
||||||
this.start.emit(res);
|
this.start.emit(res);
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
this.errorMessageId = 'START_PROCESS.ERROR.START';
|
this.errorMessageId = 'START_PROCESS.ERROR.START';
|
||||||
this.start.error(err);
|
this.error.error(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
||||||
|
import { RestVariable } from 'alfresco-js-api';
|
||||||
import { ProcessInstance, ProcessDefinitionRepresentation } from '../models/index';
|
import { ProcessInstance, ProcessDefinitionRepresentation } from '../models/index';
|
||||||
import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
|
import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
|
||||||
import { ProcessInstanceVariable } from './../models/process-instance-variable.model';
|
import { ProcessInstanceVariable } from './../models/process-instance-variable.model';
|
||||||
@@ -277,7 +278,7 @@ export class ActivitiProcessService {
|
|||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: any): Observable<ProcessInstance> {
|
startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: any, variables?: RestVariable): Observable<ProcessInstance> {
|
||||||
let startRequest: any = {
|
let startRequest: any = {
|
||||||
name: name,
|
name: name,
|
||||||
processDefinitionId: processDefinitionId
|
processDefinitionId: processDefinitionId
|
||||||
@@ -288,6 +289,9 @@ export class ActivitiProcessService {
|
|||||||
if (startFormValues) {
|
if (startFormValues) {
|
||||||
startRequest.values = startFormValues;
|
startRequest.values = startFormValues;
|
||||||
}
|
}
|
||||||
|
if (variables) {
|
||||||
|
startRequest.variables = variables;
|
||||||
|
}
|
||||||
return Observable.fromPromise(
|
return Observable.fromPromise(
|
||||||
this.apiService.getInstance().activiti.processApi.startNewProcessInstance(startRequest)
|
this.apiService.getInstance().activiti.processApi.startNewProcessInstance(startRequest)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user