[ADF-4651] fix task form cloud (#4843)

* fix task form cloud

* fix form
This commit is contained in:
Eugenio Romano
2019-06-12 20:16:04 +01:00
committed by GitHub
parent ecb8410d1b
commit b04b717296

View File

@@ -22,16 +22,18 @@ import {
import { Observable, of, forkJoin, Subject } from 'rxjs'; import { Observable, of, forkJoin, Subject } from 'rxjs';
import { switchMap, takeUntil } from 'rxjs/operators'; import { switchMap, takeUntil } from 'rxjs/operators';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { FormBaseComponent, import {
FormFieldModel, FormBaseComponent,
FormOutcomeEvent, FormFieldModel,
FormOutcomeModel, FormOutcomeEvent,
WidgetVisibilityService, FormOutcomeModel,
FormService, WidgetVisibilityService,
NotificationService, FormService,
FormRenderingService, NotificationService,
FORM_FIELD_VALIDATORS, FormRenderingService,
FormFieldValidator } from '@alfresco/adf-core'; FORM_FIELD_VALIDATORS,
FormFieldValidator
} from '@alfresco/adf-core';
import { FormCloudService } from '../services/form-cloud.service'; import { FormCloudService } from '../services/form-cloud.service';
import { FormCloud } from '../models/form-cloud.model'; import { FormCloud } from '../models/form-cloud.model';
import { TaskVariableCloud } from '../models/task-variable-cloud.model'; import { TaskVariableCloud } from '../models/task-variable-cloud.model';
@@ -104,10 +106,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
super(); super();
this.formService.formContentClicked this.formService.formContentClicked
.pipe(takeUntil(this.onDestroy$)) .pipe(takeUntil(this.onDestroy$))
.subscribe((content: any) => { .subscribe((content: any) => {
this.formContentClicked.emit(content); this.formContentClicked.emit(content);
}); });
this.formRenderingService.setComponentTypeResolver('upload', () => UploadCloudWidgetComponent, true); this.formRenderingService.setComponentTypeResolver('upload', () => UploadCloudWidgetComponent, true);
this.formRenderingService.setComponentTypeResolver('dropdown', () => DropdownCloudWidgetComponent, true); this.formRenderingService.setComponentTypeResolver('dropdown', () => DropdownCloudWidgetComponent, true);
} }
@@ -117,6 +119,8 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
if (appName && appName.currentValue) { if (appName && appName.currentValue) {
if (this.taskId && this.processInstanceId) { if (this.taskId && this.processInstanceId) {
this.getFormDefinitionWithFolderTask(this.appName, this.taskId, this.processInstanceId); this.getFormDefinitionWithFolderTask(this.appName, this.taskId, this.processInstanceId);
} else if (this.taskId) {
this.getFormByTaskId(this.appName, this.taskId);
} else if (this.formId) { } else if (this.formId) {
this.getFormById(appName.currentValue, this.formId); this.getFormById(appName.currentValue, this.formId);
} }
@@ -177,44 +181,44 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
getFormByTaskId(appName, taskId: string): Promise<FormCloud> { getFormByTaskId(appName, taskId: string): Promise<FormCloud> {
return new Promise<FormCloud>((resolve, reject) => { return new Promise<FormCloud>((resolve, reject) => {
forkJoin(this.formCloudService.getTaskForm(appName, taskId), forkJoin(this.formCloudService.getTaskForm(appName, taskId),
this.formCloudService.getTaskVariables(appName, taskId)) this.formCloudService.getTaskVariables(appName, taskId))
.pipe(takeUntil(this.onDestroy$))
.subscribe(
(data) => {
this.data = data[1];
this.formCloudRepresentationJSON = data[0];
const parsedForm = this.parseForm(this.formCloudRepresentationJSON);
this.visibilityService.refreshVisibility(<any> parsedForm);
parsedForm.validateForm();
this.form = parsedForm;
this.onFormLoaded(this.form);
resolve(this.form);
},
(error) => {
this.handleError(error);
// reject(error);
resolve(null);
}
);
});
}
getFormById(appName: string, formId: string) {
this.formCloudService
.getForm(appName, formId)
.pipe(takeUntil(this.onDestroy$)) .pipe(takeUntil(this.onDestroy$))
.subscribe( .subscribe(
(form) => { (data) => {
const parsedForm = this.parseForm(form); this.data = data[1];
this.formCloudRepresentationJSON = data[0];
const parsedForm = this.parseForm(this.formCloudRepresentationJSON);
this.visibilityService.refreshVisibility(<any> parsedForm); this.visibilityService.refreshVisibility(<any> parsedForm);
parsedForm.validateForm(); parsedForm.validateForm();
this.form = parsedForm; this.form = parsedForm;
this.onFormLoaded(this.form); this.onFormLoaded(this.form);
resolve(this.form);
}, },
(error) => { (error) => {
this.handleError(error); this.handleError(error);
// reject(error);
resolve(null);
} }
); );
});
}
getFormById(appName: string, formId: string) {
this.formCloudService
.getForm(appName, formId)
.pipe(takeUntil(this.onDestroy$))
.subscribe(
(form) => {
const parsedForm = this.parseForm(form);
this.visibilityService.refreshVisibility(<any> parsedForm);
parsedForm.validateForm();
this.form = parsedForm;
this.onFormLoaded(this.form);
},
(error) => {
this.handleError(error);
}
);
} }
getFormDefinitionWithFolderTask(appName: string, taskId: string, processInstanceId: string) { getFormDefinitionWithFolderTask(appName: string, taskId: string, processInstanceId: string) {