mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#572 activiti form model tests and code improvements
- full test coverage for model layer
This commit is contained in:
@@ -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 })
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user