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 {
|
} 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() {
|
private saveTaskForm() {
|
||||||
let form = {
|
this.formService.saveTaskForm(this.form.taskId, this.form.values).subscribe(
|
||||||
values: this.form.values
|
|
||||||
};
|
|
||||||
this.formService.saveTaskForm(this.form.taskId, form).subscribe(
|
|
||||||
(response) => {
|
(response) => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
alert('Saved');
|
alert('Saved');
|
||||||
@ -114,17 +114,16 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private completeTaskForm() {
|
private completeTaskForm(outcome?: string) {
|
||||||
let form = {
|
this.formService
|
||||||
values: this.form.values
|
.completeTaskForm(this.form.taskId, this.form.values, outcome)
|
||||||
};
|
.subscribe(
|
||||||
this.formService.completeTaskForm(this.form.taskId, form).subscribe(
|
(response) => {
|
||||||
(response) => {
|
console.log(response);
|
||||||
console.log(response);
|
alert('Saved');
|
||||||
alert('Saved');
|
},
|
||||||
},
|
(err) => window.alert(err)
|
||||||
(err) => window.alert(err)
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface FormFieldMetadata {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FormValues {
|
export interface FormValues {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
@ -77,10 +74,6 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
|
|
||||||
colspan: number = 1;
|
colspan: number = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
metadata: FormFieldMetadata = {};
|
|
||||||
|
|
||||||
constructor(form: FormModel, json?: any) {
|
constructor(form: FormModel, json?: any) {
|
||||||
super(form, json);
|
super(form, json);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Response, Http, Headers, RequestOptions } from '@angular/http';
|
import { Response, Http, Headers, RequestOptions } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
import { FormValues } from './../components/widgets/widget.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FormService {
|
export class FormService {
|
||||||
@ -48,9 +49,11 @@ export class FormService {
|
|||||||
.catch(this.handleError);
|
.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 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();
|
let options = this.getRequestOptions();
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
@ -58,9 +61,13 @@ export class FormService {
|
|||||||
.catch(this.handleError);
|
.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 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();
|
let options = this.getRequestOptions();
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
|
Loading…
x
Reference in New Issue
Block a user