task.service.ts
942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Injectable, Inject } from "ng-forward";
import { RestangularService } from "./restangular_service";
@Injectable()
@Inject("Restangular", "$q", "$log")
export class TaskService extends RestangularService<noosfero.Task> {
constructor(Restangular: restangular.IService, $q: ng.IQService, $log: ng.ILogService) {
super(Restangular, $q, $log);
}
getResourcePath() {
return "tasks";
}
getDataKeys() {
return {
singular: 'task',
plural: 'tasks'
};
}
getAllPending(params: any) {
params['all_pending'] = true;
return this.list(null, params);
}
finishTask(task: noosfero.Task) {
let element = this.getElement(task.id);
return element.customPUT(null, "finish");
}
cancelTask(task: noosfero.Task) {
let element = this.getElement(task.id);
return element.customPUT(null, "cancel");
}
}