Skip to content

Commit

Permalink
[ACA-3977] FE - Integrate new user assign API (#6157)
Browse files Browse the repository at this point in the history
* [ACA-3977] FE - Integrate new user assign API

* * Added documentation
  • Loading branch information
sivakumar414ram committed Sep 24, 2020
1 parent ffe0412 commit fe61c6d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/process-services-cloud/services/task-cloud.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ Manages task cloud.
- _taskId:_ `string` - ID of the task to update
- _payload:_ `any` - Data to update the task
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsCloudModel`](../../../lib/process-services-cloud/src/lib/task/start-task/models/task-details-cloud.model.ts)`>` - Updated task details
- **assign**(appName: `string`, taskId: `string`, assignee: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsCloudModel`](../../../lib/process-services-cloud/src/lib/task/start-task/models/task-details-cloud.model.ts)`>`<br/>
Changes assignee of the user task.
- _appName:_ `string` - Name of the app
- _taskId:_ `string` - ID of the task to update assignee
- _assignee:_ `string` - assignee to update current user task assignee
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsCloudModel`](../../../lib/process-services-cloud/src/lib/task/start-task/models/task-details-cloud.model.ts)`>` - Updated task details

## Details

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,40 @@ describe('Task Cloud Service', () => {
done();
});
});

it('should call assign api and return updated task details', (done) => {
const appName = 'task-app';
const taskId = '68d54a8f';
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnFakeTaskDetailsResults);
service.assign(appName, taskId, 'Phil Woods').subscribe(
(res) => {
expect(res.assignee).toBe('Phil Woods');
done();
});
});

it('should throw error if appName is not defined when changing task assignee', (done) => {
const appName = '';
const taskId = '68d54a8f';
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnFakeTaskDetailsResults);
service.assign(appName, taskId, 'mock-assignee').subscribe(
() => { },
(error) => {
expect(error).toBe('AppName/TaskId not configured');
done();
});
});

it('should throw error if taskId is not defined when changing task assignee', (done) => {
const appName = 'task-app';
const taskId = '';
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnFakeTaskDetailsResults);
service.assign(appName, taskId, 'mock-assignee').subscribe(
() => { },
(error) => {
expect(error).toBe('AppName/TaskId not configured');
done();
});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,29 @@ export class TaskCloudService extends BaseCloudService {
}
}

/**
* Updates the task assignee.
* @param appName Name of the app
* @param taskId ID of the task to update assignee
* @param assignee assignee to update current user task assignee
* @returns Updated task details with new assignee
*/
assign(appName: string, taskId: string, assignee: string): Observable<TaskDetailsCloudModel> {
if (appName && taskId) {
const payLoad = { 'assignee': assignee, 'taskId': taskId, 'payloadType': 'AssignTaskPayload' };
const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/assign`;

return this.post(url, payLoad).pipe(
map((res: any) => {
return res.entry;
})
);
} else {
this.logService.error('AppName and TaskId are mandatory to change/update the task assignee');
return throwError('AppName/TaskId not configured');
}
}

private isAssignedToMe(assignee: string): boolean {
const currentUser = this.identityUserService.getCurrentUserInfo().username;
return assignee === currentUser;
Expand Down

0 comments on commit fe61c6d

Please sign in to comment.