#440 complete task with custom form outcome

This commit is contained in:
Denys Vuika 2016-07-21 21:09:02 +01:00
parent 7d068a2bf8
commit e3831d7622
3 changed files with 26 additions and 27 deletions

View File

@ -87,7 +87,10 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
}
} else {
alert(`Outcome clicked: ${outcome.name}`);
// Note: Activiti is using NAME field rather than ID for outcomes
if (outcome.name) {
return this.completeTaskForm(outcome.name);
}
}
}
}
@ -102,10 +105,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
}
private saveTaskForm() {
let form = {
values: this.form.values
};
this.formService.saveTaskForm(this.form.taskId, form).subscribe(
this.formService.saveTaskForm(this.form.taskId, this.form.values).subscribe(
(response) => {
console.log(response);
alert('Saved');
@ -114,11 +114,10 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
);
}
private completeTaskForm() {
let form = {
values: this.form.values
};
this.formService.completeTaskForm(this.form.taskId, form).subscribe(
private completeTaskForm(outcome?: string) {
this.formService
.completeTaskForm(this.form.taskId, this.form.values, outcome)
.subscribe(
(response) => {
console.log(response);
alert('Saved');

View File

@ -15,9 +15,6 @@
* limitations under the License.
*/
export interface FormFieldMetadata {
[key: string]: any;
}
export interface FormValues {
[key: string]: any;
@ -77,10 +74,6 @@ export class FormFieldModel extends FormWidgetModel {
colspan: number = 1;
metadata: FormFieldMetadata = {};
constructor(form: FormModel, json?: any) {
super(form, json);

View File

@ -18,6 +18,7 @@
import { Injectable } from '@angular/core';
import { Response, Http, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { FormValues } from './../components/widgets/widget.model';
@Injectable()
export class FormService {
@ -48,9 +49,11 @@ export class FormService {
.catch(this.handleError);
}
saveTaskForm(id: string, form: { values: { [key: string]: any }}): Observable<Response> {
saveTaskForm(id: string, formValues: FormValues): Observable<Response> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}/save-form`;
let body = JSON.stringify(form);
let body = JSON.stringify({
values: formValues
});
let options = this.getRequestOptions();
return this.http
@ -58,9 +61,13 @@ export class FormService {
.catch(this.handleError);
}
completeTaskForm(id: string, form: { values: { [key: string]: any }}): Observable<Response> {
completeTaskForm(id: string, formValues: FormValues, outcome?: string): Observable<Response> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}`;
let body = JSON.stringify(form);
let data: any = { values: formValues };
if (outcome) {
data.outcome = outcome;
}
let body = JSON.stringify(data);
let options = this.getRequestOptions();
return this.http