mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
[ADF-4127] ProcessServicesCloud - add claim/unclaim directive (#4464)
* [ADF-4127] ProessServicesCloud - claim task directive * [ADF-4127] - fix doc * [ADF-4127] - revert docs changes * [ADF-4127] - revert doc changes * [ADF-4127] - fix doc and reset sourceLinker.js * [ADF-4127] - refractor task-cloud.service. add validation for claim/unclaim and fix unit tests * [ADF-4127] - fix docs files * [ADF-4127[ - add aditional complete task validation * [ADF-4127] - PR changes * [ADF-4127] - complete docs file * [ADF-4127] - more PR changes * [ADF-4127] - change Unclaim task name and wait for task to be claimed and unclaimed before emit the success event * [ADF-4127] - fix unit tests
This commit is contained in:
committed by
Maurizio Vitale
parent
0b1e5d31d8
commit
31658c0974
@@ -24,11 +24,11 @@ import {
|
||||
TranslationService,
|
||||
AppConfigService,
|
||||
UpdateNotification,
|
||||
CardViewUpdateService,
|
||||
IdentityUserService
|
||||
CardViewUpdateService
|
||||
} from '@alfresco/adf-core';
|
||||
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
||||
import { TaskCloudService } from '../services/task-cloud.service';
|
||||
import { TaskDetailsCloudModel, TaskStatusEnum } from '../../start-task/models/task-details-cloud.model';
|
||||
import { Router } from '@angular/router';
|
||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-cloud-task-header',
|
||||
@@ -61,18 +61,16 @@ export class TaskHeaderCloudComponent implements OnInit {
|
||||
properties: CardViewItem[];
|
||||
inEdit: boolean = false;
|
||||
parentTaskName: string;
|
||||
private currentUser: string;
|
||||
|
||||
constructor(
|
||||
private taskCloudService: TaskCloudService,
|
||||
private translationService: TranslationService,
|
||||
private appConfig: AppConfigService,
|
||||
private cardViewUpdateService: CardViewUpdateService,
|
||||
private identityUserService: IdentityUserService
|
||||
private router: Router,
|
||||
private cardViewUpdateService: CardViewUpdateService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.loadCurrentBpmUserId();
|
||||
if (this.appName && this.taskId) {
|
||||
this.loadTaskDetailsById(this.appName, this.taskId);
|
||||
}
|
||||
@@ -80,10 +78,6 @@ export class TaskHeaderCloudComponent implements OnInit {
|
||||
this.cardViewUpdateService.itemUpdated$.subscribe(this.updateTaskDetails.bind(this));
|
||||
}
|
||||
|
||||
loadCurrentBpmUserId(): any {
|
||||
this.currentUser = this.identityUserService.getCurrentUserInfo().username;
|
||||
}
|
||||
|
||||
loadTaskDetailsById(appName: string, taskId: string): any {
|
||||
this.taskCloudService.getTaskById(appName, taskId).subscribe(
|
||||
(taskDetails) => {
|
||||
@@ -224,55 +218,35 @@ export class TaskHeaderCloudComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
isTaskClaimable(): boolean {
|
||||
return !this.hasAssignee() && this.isCandidateMember();
|
||||
isCompleted() {
|
||||
return this.taskDetails && this.taskDetails.status && this.taskDetails.status.toUpperCase() === TaskStatusEnum.COMPLETED;
|
||||
}
|
||||
|
||||
hasAssignee(): boolean {
|
||||
return !!this.taskDetails.assignee ? true : false;
|
||||
}
|
||||
|
||||
isCandidateMember() {
|
||||
return this.taskDetails.managerOfCandidateGroup || this.taskDetails.memberOfCandidateGroup || this.taskDetails.memberOfCandidateUsers;
|
||||
}
|
||||
|
||||
isTaskClaimedByCandidateMember(): boolean {
|
||||
return this.isCandidateMember() && this.isAssignedToCurrentUser() && !this.taskDetails.isCompleted();
|
||||
}
|
||||
|
||||
isAssignedToCurrentUser(): boolean {
|
||||
return this.hasAssignee() && this.isAssignedTo(this.currentUser);
|
||||
}
|
||||
|
||||
isAssignedTo(userName): boolean {
|
||||
return this.hasAssignee() ? this.taskDetails.assignee === userName : false;
|
||||
}
|
||||
|
||||
isTaskValid() {
|
||||
return this.appName && this.taskId;
|
||||
}
|
||||
|
||||
isTaskAssigned() {
|
||||
return this.taskDetails.assignee !== undefined;
|
||||
}
|
||||
|
||||
isReadOnlyMode() {
|
||||
return !this.readOnly;
|
||||
}
|
||||
|
||||
claimTask() {
|
||||
this.taskCloudService.claimTask(this.appName, this.taskId, this.currentUser).subscribe(
|
||||
(res: any) => {
|
||||
this.loadTaskDetailsById(this.appName, this.taskId);
|
||||
this.claim.emit(this.taskId);
|
||||
});
|
||||
}
|
||||
|
||||
unclaimTask() {
|
||||
this.taskCloudService.unclaimTask(this.appName, this.taskId).subscribe(
|
||||
() => {
|
||||
this.loadTaskDetailsById(this.appName, this.taskId);
|
||||
this.unclaim.emit(this.taskId);
|
||||
});
|
||||
}
|
||||
|
||||
private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean {
|
||||
return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true;
|
||||
}
|
||||
|
||||
goBack() {
|
||||
this.router.navigate([`/cloud/${this.appName}/`]);
|
||||
}
|
||||
|
||||
onCompletedTask(event: any) {
|
||||
this.goBack();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user