From 7a26c1d53d3d814633f3f9221d8a3295326ad2dd Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Mon, 11 Sep 2017 17:01:42 +0100 Subject: [PATCH] [ADF-1521] Form string type is not rendered (#2318) * Fix missing string widget and task list loading * Update tasklist.component.ts call initStream --- .../src/components/form.component.ts | 29 ++++++----------- .../src/services/form-rendering.service.ts | 1 + .../src/components/tasklist.component.ts | 32 ++++++++++++------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/ng2-components/ng2-activiti-form/src/components/form.component.ts b/ng2-components/ng2-activiti-form/src/components/form.component.ts index 8ab15de872..a7a6d25e93 100644 --- a/ng2-components/ng2-activiti-form/src/components/form.component.ts +++ b/ng2-components/ng2-activiti-form/src/components/form.component.ts @@ -23,7 +23,7 @@ import { FormService } from './../services/form.service'; import { NodeService } from './../services/node.service'; import { ContentLinkModel } from './widgets/core/content-link.model'; import { FormFieldModel, FormModel, FormOutcomeEvent, FormOutcomeModel, FormValues, FormFieldValidator } from './widgets/core/index'; - +import { Observable } from 'rxjs/Rx'; import { WidgetVisibilityService } from './../services/widget-visibility.service'; @Component({ @@ -280,23 +280,14 @@ export class FormComponent implements OnInit, OnChanges { } } - loadFormProcessVariables(taskId: string): Promise { - return new Promise((resolve, reject) => { - this.formService.getTask(taskId).subscribe( - task => { - if (this.isAProcessTask(task)) { - this.visibilityService.getTaskProcessVariable(taskId).subscribe(_ => { - resolve(true); - }); - } else { - resolve(true); - } - }, - error => { - this.handleError(error); - resolve(false); - } - ); + findProcessVariablesByTaskId(taskId: string): Observable { + return this.formService.getTask(taskId). + switchMap((task: any) => { + if (this.isAProcessTask(task)) { + return this.visibilityService.getTaskProcessVariable(taskId); + } else { + return Observable.of({}); + } }); } @@ -306,7 +297,7 @@ export class FormComponent implements OnInit, OnChanges { getFormByTaskId(taskId: string): Promise { return new Promise((resolve, reject) => { - this.loadFormProcessVariables(this.taskId).then(_ => { + this.findProcessVariablesByTaskId(this.taskId).subscribe( (processVariables) => { this.formService .getTaskForm(taskId) .subscribe( diff --git a/ng2-components/ng2-activiti-form/src/services/form-rendering.service.ts b/ng2-components/ng2-activiti-form/src/services/form-rendering.service.ts index 9d1e7a88e0..8e64ad0877 100644 --- a/ng2-components/ng2-activiti-form/src/services/form-rendering.service.ts +++ b/ng2-components/ng2-activiti-form/src/services/form-rendering.service.ts @@ -45,6 +45,7 @@ export class FormRenderingService { private types: { [key: string]: ComponentTypeResolver } = { 'text': DefaultTypeResolver.fromType(TextWidgetComponent), + 'string': DefaultTypeResolver.fromType(TextWidgetComponent), 'integer': DefaultTypeResolver.fromType(NumberWidgetComponent), 'multi-line-text': DefaultTypeResolver.fromType(MultilineTextWidgetComponentComponent), 'boolean': DefaultTypeResolver.fromType(CheckboxWidgetComponent), diff --git a/ng2-components/ng2-activiti-tasklist/src/components/tasklist.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/tasklist.component.ts index 436d6e10f0..b85f8e0c56 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/tasklist.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/tasklist.component.ts @@ -90,6 +90,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit { * @memberOf TaskListComponent */ hasCustomDataSource: boolean = false; + isStreamLoaded = false; private defaultSchemaColumn: DataColumn[] = [ { type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true }, @@ -99,21 +100,29 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit { constructor(private taskListService: TaskListService) { } + initStream() { + if (!this.isStreamLoaded) { + this.isStreamLoaded = true; + this.taskListService.tasksList$.subscribe( + (tasks) => { + let instancesRow = this.createDataRow(tasks.data); + this.renderInstances(instancesRow); + this.selectTask(this.landingTaskId); + this.onSuccess.emit(tasks); + this.isLoading = false; + }, (error) => { + this.onError.emit(error); + this.isLoading = false; + }); + } + } + + ngOnInit() { if (this.data === undefined) { this.data = new ObjectDataTableAdapter(); } - this.taskListService.tasksList$.subscribe( - (tasks) => { - let instancesRow = this.createDataRow(tasks.data); - this.renderInstances(instancesRow); - this.selectTask(this.landingTaskId); - this.onSuccess.emit(tasks); - this.isLoading = false; - }, (error) => { - this.onError.emit(error); - this.isLoading = false; - }); + this.initStream(); } ngAfterContentInit() { @@ -143,6 +152,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit { } ngOnChanges(changes: SimpleChanges) { + this.initStream(); if (this.isPropertyChanged(changes)) { this.reload(); }