mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-1640] Start form - Get the variables from the process instance API (#2425)
* Get the variables from the process instance API /api/enterprise/process-instances/XXX instead of /api/enterprise/process-instances/382/variables because the latest api returns 404 if the process is completed * Fix unit test * Add field id
This commit is contained in:
parent
c9c22bc7c1
commit
3f1383e412
@ -102,14 +102,16 @@ export class StartFormComponent extends FormComponent implements OnChanges, OnIn
|
||||
}
|
||||
|
||||
loadStartForm(processId: string) {
|
||||
this.formService.getProcessVarablesById(processId)
|
||||
.subscribe((processVariables: any) => {
|
||||
this.formService.getProcessIntance(processId)
|
||||
.subscribe((intance: any) => {
|
||||
this.formService
|
||||
.getStartFormInstance(processId)
|
||||
.subscribe(
|
||||
form => {
|
||||
this.formName = form.name;
|
||||
form.processVariables = processVariables;
|
||||
if (intance.variables) {
|
||||
form.processVariables = intance.variables;
|
||||
}
|
||||
this.form = this.parseForm(form);
|
||||
this.form.readOnly = this.readOnlyForm;
|
||||
this.onFormLoaded(this.form);
|
||||
|
@ -205,7 +205,7 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
private getProcessVariableValue(field: any, form: FormModel) {
|
||||
let fieldName = field.name;
|
||||
if (this.isTypeaHeadFieldType(field.type)) {
|
||||
fieldName = this.getFieldNameWithLabel(field.name);
|
||||
fieldName = this.getFieldNameWithLabel(field.id);
|
||||
}
|
||||
return this.findProcessVariableValue(fieldName, form);
|
||||
}
|
||||
|
@ -365,12 +365,12 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
|
||||
it('should show typeahead value when the type is readonly', async(() => {
|
||||
typeaheadWidgetComponent.field = new FormFieldModel(
|
||||
new FormModel({ taskId: 'fake-task-id', processVariables: [{ name: 'typeahead-name_LABEL', value: 'FakeProcessValue' }] }), {
|
||||
new FormModel({ taskId: 'fake-task-id', processVariables: [{ name: 'typeahead-id_LABEL', value: 'FakeProcessValue' }] }), {
|
||||
id: 'typeahead-id',
|
||||
name: 'typeahead-name',
|
||||
type: 'readonly',
|
||||
value: '9',
|
||||
params: { field: { name: 'typeahead-name', type: 'typeahead' } }
|
||||
params: { field: { id: 'typeahead-id', name: 'typeahead-name', type: 'typeahead' } }
|
||||
});
|
||||
fixture.detectChanges();
|
||||
const trigger = fixture.debugElement.query(By.css('.mat-select-trigger')).nativeElement;
|
||||
|
@ -313,6 +313,12 @@ export class FormService {
|
||||
.catch(err => this.handleError(err));
|
||||
}
|
||||
|
||||
getProcessIntance(processId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.processApi.getProcessInstance(processId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get start form definition for a given process
|
||||
* @param processId Process definition ID
|
||||
|
Loading…
x
Reference in New Issue
Block a user