[ACA-3977] FE - Integrate new user assign API (#6157)

* [ACA-3977] FE - Integrate new user assign API

* * Added documentation
This commit is contained in:
siva kumar 2020-09-24 19:03:35 +05:30 committed by GitHub
parent ffe04120a8
commit fe61c6dbd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 0 deletions

View File

@ -79,6 +79,12 @@ Manages task cloud.
- _taskId:_ `string` - ID of the task to update - _taskId:_ `string` - ID of the task to update
- _payload:_ `any` - Data to update the task - _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 - **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 ## Details

View File

@ -410,4 +410,40 @@ describe('Task Cloud Service', () => {
done(); 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();
});
});
}); });

View File

@ -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 { private isAssignedToMe(assignee: string): boolean {
const currentUser = this.identityUserService.getCurrentUserInfo().username; const currentUser = this.identityUserService.getCurrentUserInfo().username;
return assignee === currentUser; return assignee === currentUser;