Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) => {
sivakumar414ram marked this conversation as resolved.
Show resolved Hide resolved
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