mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +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:
parent
ffe04120a8
commit
fe61c6dbd1
@ -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
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user