#440 ability to 'complete' task forms

- show ‘complete’ button when no custom outcomes present
- save and complete task form
This commit is contained in:
Denys Vuika
2016-07-21 20:08:58 +01:00
parent 4eb155af88
commit 7d068a2bf8
3 changed files with 36 additions and 4 deletions

View File

@@ -81,8 +81,14 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
if (outcome.id === '$save') {
return this.saveTaskForm();
}
if (outcome.id === '$complete') {
return this.completeTaskForm();
}
} else {
alert(`Outcome clicked: ${outcome.name}`);
}
alert(`Outcome clicked: ${outcome.name}`);
}
}
@@ -108,4 +114,17 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
);
}
private completeTaskForm() {
let form = {
values: this.form.values
};
this.formService.completeTaskForm(this.form.taskId, form).subscribe(
(response) => {
console.log(response);
alert('Saved');
},
(err) => window.alert(err)
);
}
}

View File

@@ -281,10 +281,13 @@ export class FormModel {
let saveOutcome = new FormOutcomeModel(this, { id: '$save', name: 'Save' });
saveOutcome.isSystem = true;
let systemOutcomes = [saveOutcome];
let completeOutcome = new FormOutcomeModel(this, { id: '$complete', name: 'Complete' });
completeOutcome.isSystem = true;
this.outcomes = systemOutcomes.concat(
(json.outcomes || []).map(obj => new FormOutcomeModel(this, obj))
let customOutcomes = (json.outcomes || []).map(obj => new FormOutcomeModel(this, obj));
this.outcomes = [saveOutcome].concat(
customOutcomes.length > 0 ? customOutcomes : [completeOutcome]
);
}
}

View File

@@ -58,6 +58,16 @@ export class FormService {
.catch(this.handleError);
}
completeTaskForm(id: string, form: { values: { [key: string]: any }}): Observable<Response> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}`;
let body = JSON.stringify(form);
let options = this.getRequestOptions();
return this.http
.post(url, body, options)
.catch(this.handleError);
}
getTaskForm(id: string): Observable<any> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}`;
let options = this.getRequestOptions();