diff --git a/ng2-components/ng2-activiti-form/src/components/start-form.component.ts b/ng2-components/ng2-activiti-form/src/components/start-form.component.ts index f85c9a98f8..0a9b719219 100644 --- a/ng2-components/ng2-activiti-form/src/components/start-form.component.ts +++ b/ng2-components/ng2-activiti-form/src/components/start-form.component.ts @@ -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); diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/form-field.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/form-field.model.ts index 8bb1a5a411..add51dee81 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/form-field.model.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/core/form-field.model.ts @@ -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); } diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts b/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts index 8450b97a4a..f159a7a3cb 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts @@ -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; diff --git a/ng2-components/ng2-activiti-form/src/services/form.service.ts b/ng2-components/ng2-activiti-form/src/services/form.service.ts index 93354784e4..a32eba9ae0 100644 --- a/ng2-components/ng2-activiti-form/src/services/form.service.ts +++ b/ng2-components/ng2-activiti-form/src/services/form.service.ts @@ -313,6 +313,12 @@ export class FormService { .catch(err => this.handleError(err)); } + getProcessIntance(processId: string): Observable { + 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