mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3977] FE - Integrate new user assign API (#6157)
* [ACA-3977] FE - Integrate new user assign API * * Added documentation
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user