mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#440 ability to 'complete' task forms
- show ‘complete’ button when no custom outcomes present - save and complete task form
This commit is contained in:
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user