mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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"
|
||||
|
@@ -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', () => {
|
||||
|
18
lib/process-services-cloud/src/lib/task/models/public-api.ts
Normal file
18
lib/process-services-cloud/src/lib/task/models/public-api.ts
Normal 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';
|
@@ -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';
|
||||
|
@@ -11,6 +11,7 @@
|
||||
[actions]="showActions"
|
||||
[actionsPosition]="actionsPosition"
|
||||
[contextMenu]="showContextMenu"
|
||||
[resolverFn]="boundReplacePriorityValues"
|
||||
(showRowActionsMenu)="onShowRowActionsMenu($event)"
|
||||
(showRowContextMenu)="onShowRowContextMenu($event)"
|
||||
(executeRowAction)="onExecuteRowAction($event)"
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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();
|
||||
|
@@ -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]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -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));
|
||||
|
Reference in New Issue
Block a user