#572 activiti form model tests and code improvements

- full test coverage for model layer
This commit is contained in:
Denys Vuika
2016-08-16 13:55:50 +01:00
parent 42cfdd093d
commit c55e976f67
5 changed files with 274 additions and 47 deletions

View File

@@ -214,7 +214,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
.getTaskForm(taskId)
.subscribe(
form => {
this.form = new FormModel(form, data, null, this.readOnly);
this.form = new FormModel(form, data, this.readOnly);
this.formLoaded.emit(this.form.values);
},
err => console.log(err)
@@ -227,7 +227,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
.subscribe(
form => {
console.log('Get Form By definition Id', form);
this.form = new FormModel(form, this.data, this.formSaved, this.readOnly);
this.form = this.parseForm(form);
this.formLoaded.emit(this.form.values);
},
err => console.log(err)
@@ -242,7 +242,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
this.formService.getFormDefinitionById(id).subscribe(
form => {
console.log('Get Form By Form definition Name', form);
this.form = new FormModel(form, this.data, this.formSaved, this.readOnly);
this.form = this.parseForm(form);
this.formLoaded.emit(this.form.values);
},
err => console.log(err)
@@ -273,4 +273,18 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
(err) => console.log(err)
);
}
private parseForm(json: any): FormModel {
let form = new FormModel(json, this.data, this.readOnly);
if (!json.fields) {
form.outcomes = this.getFormDefinitionOutcomes(form);
}
return form;
}
private getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] {
return [
new FormOutcomeModel(form, { id: '$custom', name: 'Save', isSystem: true })
];
}
}