Provide a way to retrieve the task filter by Id or by name (#1815)

* Provide a way to retrieve the task filter by Id or by name

* Update activiti-tasklist.service.ts

* Update activiti-tasklist.service.spec.ts

* Removed space
This commit is contained in:
Maurizio Vitale
2017-04-18 10:22:55 +01:00
committed by Mario Romano
parent 88edb1697a
commit 87d889e8af
2 changed files with 71 additions and 7 deletions

View File

@@ -101,6 +101,46 @@ describe('Activiti TaskList Service', () => {
});
});
it('should return the task filter by id', (done) => {
service.getTaskFilterById('2').subscribe(
(res: FilterRepresentationModel) => {
expect(res).toBeDefined();
expect(res.id).toEqual('2');
expect(res.name).toEqual('FakeMyTasks');
expect(res.filter.sort).toEqual('created-desc');
expect(res.filter.state).toEqual('open');
expect(res.filter.assignment).toEqual('fake-assignee');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeFilters)
});
});
it('should return the task filter by name', (done) => {
service.getTaskFilterByName('FakeMyTasks').subscribe(
(res: FilterRepresentationModel) => {
expect(res).toBeDefined();
expect(res.id).toEqual('2');
expect(res.name).toEqual('FakeMyTasks');
expect(res.filter.sort).toEqual('created-desc');
expect(res.filter.state).toEqual('open');
expect(res.filter.assignment).toEqual('fake-assignee');
done();
}
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeFilters)
});
});
it('should call the api withthe appId', (done) => {
spyOn(service, 'callApiTaskFilters').and.returnValue((fakeAppPromise));

View File

@@ -35,7 +35,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the Deployed app
* Retrieve all the Deployed app
* @returns {Observable<any>}
*/
getDeployedApplications(name?: string): Observable<any> {
@@ -50,7 +50,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the Tasks filters
* Retrieve all the Tasks filters
* @returns {Observable<any>}
*/
getTaskListFilters(appId?: string): Observable<any> {
@@ -65,6 +65,30 @@ export class ActivitiTaskListService {
}).catch(err => this.handleError(err));
}
/**
* Retrieve the Tasks filter by id
* @param taskId - string - The id of the filter
* @returns {Observable<FilterRepresentationModel>}
*/
getTaskFilterById(taskId: string, appId?: string): Observable<FilterRepresentationModel> {
return Observable.fromPromise(this.callApiTaskFilters(appId))
.map((response: any) => {
return response.data.find(filter => filter.id === taskId);
}).catch(err => this.handleError(err));
}
/**
* Retrieve the Tasks filter by name
* @param taskName - string - The name of the filter
* @returns {Observable<FilterRepresentationModel>}
*/
getTaskFilterByName(taskName: string, appId?: string): Observable<FilterRepresentationModel> {
return Observable.fromPromise(this.callApiTaskFilters(appId))
.map((response: any) => {
return response.data.find(filter => filter.name === taskName);
}).catch(err => this.handleError(err));
}
/**
* Return all the filters in the list where the task id belong
* @param taskId - string
@@ -108,7 +132,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the tasks filtered by filterModel
* Retrieve all the tasks filtered by filterModel
* @param filter - TaskFilterRepresentationModel
* @returns {any}
*/
@@ -124,7 +148,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the task details
* Retrieve all the task details
* @param id - taskId
* @returns {<TaskDetailsModel>}
*/
@@ -137,7 +161,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the task's comments
* Retrieve all the task's comments
* @param id - taskId
* @returns {<Comment[]>}
*/
@@ -155,7 +179,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the task's checklist
* Retrieve all the task's checklist
* @param id - taskId
* @returns {TaskDetailsModel}
*/
@@ -172,7 +196,7 @@ export class ActivitiTaskListService {
}
/**
* Retrive all the form shared with this user
* Retrieve all the form shared with this user
* @returns {TaskDetailsModel}
*/
getFormList(): Observable<Form []> {