mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
#440 complete task with custom form outcome
This commit is contained in:
parent
7d068a2bf8
commit
e3831d7622
@ -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,17 +114,16 @@ 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)
|
||||
);
|
||||
private completeTaskForm(outcome?: string) {
|
||||
this.formService
|
||||
.completeTaskForm(this.form.taskId, this.form.values, outcome)
|
||||
.subscribe(
|
||||
(response) => {
|
||||
console.log(response);
|
||||
alert('Saved');
|
||||
},
|
||||
(err) => window.alert(err)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user