[ADF-4471] TaskCloud - disable editable fields when the task is unclaimed (#4680)

* [ADF-4471] TaskCloud - task header disabled when the task is unclaimed

* [ADF-4471] - fix unit test

* [ADF-4471] - pr changes

* [ADF-4471] - add return type
This commit is contained in:
Silviu Popa
2019-05-14 17:30:35 +03:00
committed by Maurizio Vitale
parent d1bc5a608a
commit 4a363c731b
4 changed files with 28 additions and 7 deletions

View File

@@ -113,6 +113,11 @@ describe('Task Cloud Service', () => {
expect(canCompleteTaskResult).toEqual(false);
});
it('should verify if the task is editable', () => {
const isTaskEditable = service.isTaskEditable(assignedTaskDetailsCloudMock);
expect(isTaskEditable).toEqual(true);
});
it('should complete task with owner as null', async(() => {
const appName = 'simple-app';
const taskId = '68d54a8f';

View File

@@ -76,8 +76,16 @@ export class TaskCloudService extends BaseCloudService {
* @returns Boolean value if the task can be completed
*/
canCompleteTask(taskDetails: TaskDetailsCloudModel): boolean {
const currentUser = this.identityUserService.getCurrentUserInfo().username;
return taskDetails && taskDetails.assignee && taskDetails.assignee === currentUser && taskDetails.isAssigned();
return taskDetails && taskDetails.isAssigned() && this.isAssignedToMe(taskDetails.assignee);
}
/**
* Validate if a task is editable.
* @param taskDetails task details object
* @returns Boolean value if the task is editable
*/
isTaskEditable(taskDetails: TaskDetailsCloudModel): boolean {
return taskDetails && taskDetails.isAssigned() && this.isAssignedToMe(taskDetails.assignee);
}
/**
@@ -211,6 +219,11 @@ export class TaskCloudService extends BaseCloudService {
}
}
private isAssignedToMe(assignee: string): boolean {
const currentUser = this.identityUserService.getCurrentUserInfo().username;
return assignee === currentUser;
}
private buildCompleteTaskUrl(appName: string, taskId: string): string {
return `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/complete`;
}

View File

@@ -5,9 +5,8 @@
<mat-card-content>
<adf-card-view
[properties]="properties"
[editable]="!taskDetails.isCompleted()">
[editable]="isTaskEditable()">
</adf-card-view>
</mat-card-content>
</mat-card>
</div>

View File

@@ -230,14 +230,18 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
return !!this.taskDetails.assignee ? true : false;
}
isTaskValid() {
return (this.appName || this.appName === '') && this.taskId;
isTaskValid(): boolean {
return (this.appName || this.appName === '') && !!this.taskId;
}
isTaskAssigned() {
isTaskAssigned(): boolean {
return this.taskDetails.assignee !== undefined;
}
isTaskEditable(): boolean {
return this.taskCloudService.isTaskEditable(this.taskDetails);
}
private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean {
return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true;
}