[AAE-4077] - TaskCloud: Refactor priority (#6385)

* [AAE-4077] - TaskCloud: Refactor priority

* export default priority values

* Fix e2e tests

* fix navigation from task-list

* Update task-list-properties-sort.e2e.ts

* Fix lint

Co-authored-by: Cano <david.cano.nieto@gmail.com>
This commit is contained in:
Silviu Popa 2020-11-26 19:38:40 +02:00 committed by GitHub
parent 5086620991
commit f73dece82d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 99 additions and 53 deletions

View File

@ -39,9 +39,8 @@ describe('Edit task filters and task list properties', () => {
const simpleApp = browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.name;
const candidateBaseApp = browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.name;
let createdTask, notDisplayedTask, priorityTask, subTask,
let createdTask, notDisplayedTask, noPriorityTask, lowPriorityTask, normalPriorityTask, hightPriorityTask, subTask,
otherOwnerTask, testUser, groupInfo;
const priority = 1;
beforeAll(async () => {
await apiService.loginWithProfile('identityAdmin');
@ -59,8 +58,14 @@ describe('Edit task filters and task list properties', () => {
createdTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), simpleApp);
await tasksService.claimTask(createdTask.entry.id, simpleApp);
priorityTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), simpleApp, { priority: priority });
await tasksService.claimTask(priorityTask.entry.id, simpleApp);
noPriorityTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), simpleApp, { priority: 0 });
lowPriorityTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), simpleApp, { priority: 1 });
normalPriorityTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), simpleApp, { priority: 2 });
hightPriorityTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), simpleApp, { priority: 3 });
await tasksService.claimTask(noPriorityTask.entry.id, simpleApp);
await tasksService.claimTask(lowPriorityTask.entry.id, simpleApp);
await tasksService.claimTask(normalPriorityTask.entry.id, simpleApp);
await tasksService.claimTask(hightPriorityTask.entry.id, simpleApp);
notDisplayedTask = await tasksService.createStandaloneTask(StringUtil.generateRandomString(), candidateBaseApp);
await tasksService.claimTask(notDisplayedTask.entry.id, candidateBaseApp);
@ -193,15 +198,14 @@ describe('Edit task filters and task list properties', () => {
});
it('[C290087] Should display tasks ordered by priority when Priority is selected from sort dropdown', async () => {
await tasksCloudDemoPage.editTaskFilterCloudComponent().clearAssignee();
await tasksCloudDemoPage.editTaskFilterCloudComponent().setStatusFilterDropDown('ALL');
await tasksCloudDemoPage.editTaskFilterCloudComponent().setSortFilterDropDown('Priority');
await tasksCloudDemoPage.editTaskFilterCloudComponent().setOrderFilterDropDown('ASC');
await expect(await tasksCloudDemoPage.taskListCloudComponent().getDataTable().checkListIsSorted('ASC', 'Priority', 'NUMBER')).toBe(true);
await expect(await tasksCloudDemoPage.taskListCloudComponent().getDataTable().checkListIsSorted('ASC', 'Priority', 'PRIORITY')).toBe(true);
await tasksCloudDemoPage.editTaskFilterCloudComponent().setOrderFilterDropDown('DESC');
await expect(await tasksCloudDemoPage.taskListCloudComponent().getDataTable().checkListIsSorted('DESC', 'Priority', 'NUMBER')).toBe(true);
await expect(await tasksCloudDemoPage.taskListCloudComponent().getDataTable().checkListIsSorted('DESC', 'Priority', 'PRIORITY')).toBe(true);
});
it('[C307115] Should display tasks sorted by owner when owner is selected from sort dropdown', async () => {

View File

@ -56,7 +56,7 @@ describe('Task filters cloud', () => {
assignedTaskName = StringUtil.generateRandomString(), deletedTaskName = StringUtil.generateRandomString();
let assignedTask, deletedTask, testUser, groupInfo;
const orderByNameAndPriority = ['cCreatedTask', 'dCreatedTask', 'eCreatedTask'];
let priority = 30;
let priority = 1;
const nrOfTasks = 3;
beforeAll(async () => {
@ -77,7 +77,7 @@ describe('Task filters cloud', () => {
await tasksService.deleteTask(deletedTask.entry.id, simpleApp);
for (let i = 0; i < nrOfTasks; i++) {
await tasksService.createStandaloneTask(orderByNameAndPriority[i], simpleApp, { priority: priority });
priority = priority + 20;
priority = priority + 1;
}
const processDefinition = await processDefinitionService

View File

@ -14,6 +14,5 @@
"C277000": "ADF-5283 Fix Permission Flaky test",
"C277003": "ADF-5283 Fix Permission Flaky test",
"C277004": "ADF-5283 Fix Permission Flaky test",
"C299187": "ADF-5285 Failing aspect test",
"C290087": "https://alfresco.atlassian.net/browse/ADF-5292"
"C299187": "ADF-5285 Failing aspect test"
}

View File

@ -137,8 +137,8 @@
<div *ngSwitchCase="'icon'" class="adf-cell-value">
<mat-icon>{{ data.getValue(row, col) }}</mat-icon>
</div>
<div *ngSwitchCase="'date'" class="adf-cell-value" [attr.tabindex]="data.getValue(row, col)? 0 : -1"
[attr.data-automation-id]="'date_' + (data.getValue(row, col) | adfLocalizedDate: 'medium') ">
<div *ngSwitchCase="'date'" class="adf-cell-value" [attr.tabindex]="data.getValue(row, col, resolverFn)? 0 : -1"
[attr.data-automation-id]="'date_' + (data.getValue(row, col, resolverFn) | adfLocalizedDate: 'medium') ">
<adf-date-cell class="adf-datatable-center-date-column-ie"
[data]="data"
[column]="col"
@ -147,8 +147,8 @@
[tooltip]="getCellTooltip(row, col)">
</adf-date-cell>
</div>
<div *ngSwitchCase="'location'" [attr.tabindex]="data.getValue(row, col)? 0 : -1" class="adf-cell-value"
[attr.data-automation-id]="'location' + data.getValue(row, col)">
<div *ngSwitchCase="'location'" [attr.tabindex]="data.getValue(row, col, resolverFn)? 0 : -1" class="adf-cell-value"
[attr.data-automation-id]="'location' + data.getValue(row, col, resolverFn)">
<adf-location-cell
[data]="data"
[column]="col"
@ -157,8 +157,8 @@
[tooltip]="getCellTooltip(row, col)">
</adf-location-cell>
</div>
<div *ngSwitchCase="'fileSize'" [attr.tabindex]="data.getValue(row, col)? 0 : -1" class="adf-cell-value"
[attr.data-automation-id]="'fileSize_' + data.getValue(row, col)">
<div *ngSwitchCase="'fileSize'" [attr.tabindex]="data.getValue(row, col, resolverFn)? 0 : -1" class="adf-cell-value"
[attr.data-automation-id]="'fileSize_' + data.getValue(row, col, resolverFn)">
<adf-filesize-cell class="adf-datatable-center-size-column-ie"
[data]="data"
[column]="col"
@ -167,8 +167,8 @@
[tooltip]="getCellTooltip(row, col)">
</adf-filesize-cell>
</div>
<div *ngSwitchCase="'text'" [attr.tabindex]="data.getValue(row, col)? 0 : -1" class="adf-cell-value"
[attr.data-automation-id]="'text_' + data.getValue(row, col)">
<div *ngSwitchCase="'text'" [attr.tabindex]="data.getValue(row, col, resolverFn)? 0 : -1" class="adf-cell-value"
[attr.data-automation-id]="'text_' + data.getValue(row, col, resolverFn)">
<adf-datatable-cell
[copyContent]="col.copyContent"
[data]="data"
@ -178,7 +178,7 @@
[tooltip]="getCellTooltip(row, col)">
</adf-datatable-cell>
</div>
<div *ngSwitchCase="'json'" [attr.tabindex]="data.getValue(row, col)? 0 : -1" class="adf-cell-value">
<div *ngSwitchCase="'json'" [attr.tabindex]="data.getValue(row, col, resolverFn)? 0 : -1" class="adf-cell-value">
<adf-json-cell
[editable]="col.editable"
[data]="data"

View File

@ -1268,15 +1268,15 @@ describe('DataTable', () => {
const id1 = element.querySelector('[data-automation-id="text_1');
const id2 = element.querySelector('[data-automation-id="text_2');
const names = element.querySelectorAll('[data-automation-id="text_undefined"]');
const namesId1 = element.querySelector('[data-automation-id="text_foo - bar"]');
const namesId2 = element.querySelector('[data-automation-id="text_bar - baz"]');
expect(id1.innerText).toEqual('1');
expect(names[0].innerText).toEqual('foo - bar');
expect(namesId1.innerText).toEqual('foo - bar');
expect(id2.innerText).toEqual('2');
expect(names[1].innerText).toEqual('bar - baz');
expect(namesId2.innerText).toEqual('bar - baz');
expect(dataTable.data.getRows().length).toEqual(2);
expect(dataTable.resolverFn).toHaveBeenCalledTimes(4);
});
it('should update data columns when columns input changes', () => {

View File

@ -0,0 +1,18 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './task.model';

View File

@ -21,6 +21,7 @@ export * from './start-task/public-api';
export * from './task-header/public-api';
export * from './task-form/public-api';
export * from './directives/public-api';
export * from './models/public-api';
export * from './services/task-cloud.service';
export * from './services/start-task-cloud.service';

View File

@ -11,6 +11,7 @@
[actions]="showActions"
[actionsPosition]="actionsPosition"
[contextMenu]="showContextMenu"
[resolverFn]="boundReplacePriorityValues"
(showRowActionsMenu)="onShowRowActionsMenu($event)"
(showRowContextMenu)="onShowRowContextMenu($event)"
(executeRowAction)="onExecuteRowAction($event)"

View File

@ -20,13 +20,14 @@ import {
AppConfigService, UserPreferencesService,
DataTableSchema, UserPreferenceValues,
PaginatedComponent, PaginationModel,
DataRowEvent, CustomEmptyContentTemplateDirective, DataCellEvent, DataRowActionEvent
DataRowEvent, CustomEmptyContentTemplateDirective, DataCellEvent, DataRowActionEvent, DataRow, DataColumn
} from '@alfresco/adf-core';
import { taskPresetsCloudDefaultModel } from '../models/task-preset-cloud.model';
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
import { BehaviorSubject, Subject } from 'rxjs';
import { TaskListCloudSortingModel } from '../models/task-list-sorting.model';
import { takeUntil } from 'rxjs/operators';
import { TaskCloudService } from '../../services/task-cloud.service';
@Directive()
// tslint:disable-next-line: directive-class-suffix
@ -114,10 +115,12 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme
selectedInstances: any[];
formattedSorting: any[];
private defaultSorting = { key: 'startDate', direction: 'desc' };
boundReplacePriorityValues: Function;
private onDestroy$ = new Subject<boolean>();
constructor(appConfigService: AppConfigService,
private taskCloudService: TaskCloudService,
private userPreferences: UserPreferencesService,
presetKey: string) {
super(appConfigService, presetKey, taskPresetsCloudDefaultModel);
@ -129,6 +132,7 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme
totalItems: 0
});
this.boundReplacePriorityValues = this.replacePriorityValues.bind(this);
}
ngOnInit() {
@ -251,6 +255,15 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme
return sorting && sorting.length && sorting[0].orderBy && sorting[0].direction;
}
replacePriorityValues(row: DataRow, column: DataColumn) {
return column.key.split('.').reduce((source, key) => {
if (key === 'priority' && typeof(source[key]) === 'number') {
return source[key] = this.taskCloudService.getPriorityLabel(source[key]);
}
return source ? source[key] : '';
}, row.obj);
}
abstract load(requestNode);
abstract createRequestNode();
}

View File

@ -22,6 +22,7 @@ import {
import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model';
import { BaseTaskListCloudComponent } from './base-task-list-cloud.component';
import { ServiceTaskListCloudService } from '../services/service-task-list-cloud.service';
import { TaskCloudService } from '../../services/task-cloud.service';
@Component({
selector: 'adf-cloud-service-task-list',
@ -38,8 +39,9 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
constructor(private serviceTaskListCloudService: ServiceTaskListCloudService,
appConfigService: AppConfigService,
taskCloudService: TaskCloudService,
userPreferences: UserPreferencesService) {
super(appConfigService, userPreferences, ServiceTaskListCloudComponent.PRESET_KEY);
super(appConfigService, taskCloudService, userPreferences, ServiceTaskListCloudComponent.PRESET_KEY);
}
load(requestNode: ServiceTaskQueryCloudRequestModel) {

View File

@ -208,7 +208,7 @@ describe('TaskListCloudComponent', () => {
expect(component.rows[0].entry['createdDate']).toBe(1538059139420);
expect(component.rows[0].entry['dueDate']).toBeNull();
expect(component.rows[0].entry['claimedDate']).toBeNull();
expect(component.rows[0].entry['priority']).toBe('ADF_CLOUD_TASK_LIST.PROPERTIES.PRIORITY_VALUES.NOT_SET');
expect(component.rows[0].entry['priority']).toBe(0);
expect(component.rows[0].entry['category']).toBeNull();
expect(component.rows[0].entry['processDefinitionId']).toBeNull();
expect(component.rows[0].entry['processInstanceId']).toBeNull();

View File

@ -20,9 +20,7 @@ import { AppConfigService, UserPreferencesService } from '@alfresco/adf-core';
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
import { TaskListCloudService } from '../services/task-list-cloud.service';
import { BaseTaskListCloudComponent } from './base-task-list-cloud.component';
import { map } from 'rxjs/operators';
import { TaskCloudService } from '../../services/task-cloud.service';
import { TaskCloudEntryModel, TaskCloudNodePaging } from '../models/task-cloud.model';
@Component({
selector: 'adf-cloud-task-list',
@ -135,17 +133,15 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
candidateGroupId: string = '';
constructor(private taskListCloudService: TaskListCloudService,
private taskCloudService: TaskCloudService,
appConfigService: AppConfigService,
taskCloudService: TaskCloudService,
userPreferences: UserPreferencesService) {
super(appConfigService, userPreferences, TaskListCloudComponent.PRESET_KEY);
super(appConfigService, taskCloudService, userPreferences, TaskListCloudComponent.PRESET_KEY);
}
load(requestNode: TaskQueryCloudRequestModel) {
this.isLoading = true;
this.taskListCloudService.getTaskByRequest(requestNode).pipe(
map((tasks: TaskCloudNodePaging) => this.replacePriorityValues(tasks)
)).subscribe(
this.taskListCloudService.getTaskByRequest(requestNode).subscribe(
(tasks) => {
this.rows = tasks.list.entries;
this.success.emit(tasks);
@ -190,22 +186,4 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
};
return new TaskQueryCloudRequestModel(requestNode);
}
private replacePriorityValues(tasks: TaskCloudNodePaging) {
const entries = tasks.list.entries.map((item: TaskCloudEntryModel) => {
return {
entry: {
...item.entry,
['priority']: this.taskCloudService.getPriorityLabel(item.entry?.priority)
}
};
});
return {
list: {
...tasks.list,
entries: [...entries]
}
};
}
}

View File

@ -171,6 +171,8 @@ export class DataTableComponentPage {
sortedList = sortedList.sort();
} else if (listType.toLocaleLowerCase() === 'number') {
sortedList = sortedList.sort((a, b) => a - b);
} else if (listType.toLocaleLowerCase() === 'priority') {
sortedList = sortedList.sort(this.sortPriority);
}
if (sortOrder.toLocaleLowerCase() === 'desc') {
@ -180,6 +182,34 @@ export class DataTableComponentPage {
return initialList.toString() === sortedList.toString();
}
sortPriority(a: string, b: string) {
if (a === b) {
return 0;
}
if (a.toLocaleLowerCase() === 'not set') {
return -1;
}
if (a.toLocaleLowerCase() === 'low') {
if (b === 'not set') {
return 1;
} else {
return -1;
}
}
if (a.toLocaleLowerCase() === 'normal') {
if (b.toLocaleLowerCase() === 'high') {
return -1;
} else {
return 1;
}
}
return 1;
}
async rightClickOnRow(columnName: string, columnValue: string): Promise<void> {
await this.rightClickOnItem(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsVisible(element(by.id('adf-context-menu-content')));
@ -198,7 +228,7 @@ export class DataTableComponentPage {
async rightClickOnItem(columnName: string, columnValue: string): Promise<void> {
const row = this.getRow(columnName, columnValue);
await BrowserActions.rightClick(row);
}
}
getFileHyperlink(filename: string): ElementFinder {
return element(by.cssContainingText('adf-name-column[class*="adf-datatable-link"] span', filename));