mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-3082] Task Filter - Custom Task filters don't work (#3402)
* [ADF-3082] Custom Task filters don't work. * Added an sorting input to the datatable. * Updated documentation for the recent changes. * Added testcases for the recent changes. * [ADF-3082] Custom Task filters don't work * Added a sorting input to the datatable * Added testcases to the recent changes. * Updated doc for the recent changes. * * Refactored task/process list dataSort. * * Refactored process/task list datasort method
This commit is contained in:
parent
a11766aa23
commit
9eae0fcc8f
@ -40,7 +40,6 @@
|
|||||||
[assignment]="taskFilter?.filter?.assignment"
|
[assignment]="taskFilter?.filter?.assignment"
|
||||||
[state]="taskFilter?.filter?.state"
|
[state]="taskFilter?.filter?.state"
|
||||||
[sort]="taskFilter?.filter?.sort"
|
[sort]="taskFilter?.filter?.sort"
|
||||||
[data]="dataTasks"
|
|
||||||
[landingTaskId]="currentTaskId"
|
[landingTaskId]="currentTaskId"
|
||||||
(rowClick)="onTaskRowClick($event)"
|
(rowClick)="onTaskRowClick($event)"
|
||||||
(success)="onSuccessTaskList($event)"
|
(success)="onSuccessTaskList($event)"
|
||||||
@ -144,7 +143,6 @@
|
|||||||
[page]="processPage"
|
[page]="processPage"
|
||||||
[size]="paginationPageSize"
|
[size]="paginationPageSize"
|
||||||
[sort]="processFilter?.filter?.sort"
|
[sort]="processFilter?.filter?.sort"
|
||||||
[data]="dataProcesses"
|
|
||||||
(rowClick)="onProcessRowClick($event)"
|
(rowClick)="onProcessRowClick($event)"
|
||||||
(row-dblclick)="onProcessRowDblClick($event)"
|
(row-dblclick)="onProcessRowDblClick($event)"
|
||||||
(success)="onSuccessProcessList($event)">
|
(success)="onSuccessProcessList($event)">
|
||||||
|
@ -54,11 +54,7 @@ import {
|
|||||||
} from '@alfresco/adf-process-services';
|
} from '@alfresco/adf-process-services';
|
||||||
import { LogService } from '@alfresco/adf-core';
|
import { LogService } from '@alfresco/adf-core';
|
||||||
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import {
|
import { ObjectDataRow } from '@alfresco/adf-core';
|
||||||
DataSorting,
|
|
||||||
ObjectDataRow,
|
|
||||||
ObjectDataTableAdapter
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { Subscription } from 'rxjs/Subscription';
|
import { Subscription } from 'rxjs/Subscription';
|
||||||
import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component';
|
import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component';
|
||||||
import { DemoFieldValidator } from './demo-field-validator';
|
import { DemoFieldValidator } from './demo-field-validator';
|
||||||
@ -146,8 +142,6 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
blobFile: any;
|
blobFile: any;
|
||||||
flag = true;
|
flag = true;
|
||||||
|
|
||||||
dataTasks: ObjectDataTableAdapter;
|
|
||||||
dataProcesses: ObjectDataTableAdapter;
|
|
||||||
presetColoum = 'default';
|
presetColoum = 'default';
|
||||||
showProcessPagination = false;
|
showProcessPagination = false;
|
||||||
|
|
||||||
@ -167,8 +161,6 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
formService: FormService,
|
formService: FormService,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private preferenceService: UserPreferencesService) {
|
private preferenceService: UserPreferencesService) {
|
||||||
this.dataTasks = new ObjectDataTableAdapter();
|
|
||||||
this.dataTasks.setSorting(new DataSorting('created', 'desc'));
|
|
||||||
|
|
||||||
|
|
||||||
this.defaultProcessName = this.appConfig.get<string>('adf-start-process.name');
|
this.defaultProcessName = this.appConfig.get<string>('adf-start-process.name');
|
||||||
|
@ -146,6 +146,7 @@ export class DataTableDemo {
|
|||||||
| rows | `any[]` | \[] | The rows that the datatable will show. |
|
| rows | `any[]` | \[] | The rows that the datatable will show. |
|
||||||
| selectionMode | `string` | "single" | Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
|
| selectionMode | `string` | "single" | Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
|
||||||
| showHeader | `boolean` | true | Toggles the header. |
|
| showHeader | `boolean` | true | Toggles the header. |
|
||||||
|
| sorting | `any[]` | `[]` | Define the sorting order of the datatable. Possible values are : [`created`, `desc`], [`created`, `asc`], [`due`, `desc`], [`due`, `asc`] |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -121,6 +121,22 @@ information defined in `app.config.json` as in the example below:
|
|||||||
</adf-process-instance-list>
|
</adf-process-instance-list>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Setting Sorting Order for the list
|
||||||
|
|
||||||
|
you can pass sorting order as shown in the example below:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Possible values are : `created-desc`, `created-asc`, `ended-desc`, `ended-asc` |
|
||||||
|
let sortParam = 'created-desc';
|
||||||
|
```
|
||||||
|
|
||||||
|
```html
|
||||||
|
<adf-process-instance-list
|
||||||
|
[appId]="'1'"
|
||||||
|
[sort]="sortParam">
|
||||||
|
</adf-process-instance-list>
|
||||||
|
```
|
||||||
|
|
||||||
<!-- {% endraw %} -->
|
<!-- {% endraw %} -->
|
||||||
|
|
||||||
### Pagination strategy
|
### Pagination strategy
|
||||||
|
@ -187,6 +187,22 @@ You can use an HTML-based schema and an `app.config.json` custom schema declarat
|
|||||||
</adf-tasklist>
|
</adf-tasklist>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Setting Sorting Order for the list
|
||||||
|
|
||||||
|
you can pass sorting order as shown in the example below:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Possible values are : `created-desc`, `created-asc`, `due-desc`, `due-asc`
|
||||||
|
let sortParam = 'created-desc';
|
||||||
|
```
|
||||||
|
|
||||||
|
```html
|
||||||
|
<adf-tasklist
|
||||||
|
[appId]="'1'"
|
||||||
|
[sort]="sortParam">
|
||||||
|
</adf-tasklist>
|
||||||
|
```
|
||||||
|
|
||||||
<!-- {% endraw %} -->
|
<!-- {% endraw %} -->
|
||||||
|
|
||||||
### Pagination strategy
|
### Pagination strategy
|
||||||
|
@ -207,6 +207,62 @@ describe('DataTable', () => {
|
|||||||
expect(element.querySelector('[data-automation-id="text_FAKE"]')).not.toBeNull();
|
expect(element.querySelector('[data-automation-id="text_FAKE"]')).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set rows to the data when rows defined', () => {
|
||||||
|
const dataRows =
|
||||||
|
[
|
||||||
|
{ name: 'test1' },
|
||||||
|
{ name: 'test2' },
|
||||||
|
{ name: 'test3' },
|
||||||
|
{ name: 'test4' }
|
||||||
|
];
|
||||||
|
dataTable.data = new ObjectDataTableAdapter([],
|
||||||
|
[new ObjectDataColumn({ key: 'name' })]
|
||||||
|
);
|
||||||
|
|
||||||
|
dataTable.ngOnChanges({
|
||||||
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const rows = dataTable.data.getRows();
|
||||||
|
expect(rows[0].getValue('name')).toEqual('test1');
|
||||||
|
expect(rows[1].getValue('name')).toEqual('test2');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set sort order if sorting is defined', () => {
|
||||||
|
const dataSortObj = new DataSorting('created', 'desc');
|
||||||
|
|
||||||
|
const sort = [ 'created', 'desc' ];
|
||||||
|
dataTable.data = new ObjectDataTableAdapter([],
|
||||||
|
[new ObjectDataColumn({ key: 'name' })]
|
||||||
|
);
|
||||||
|
|
||||||
|
dataTable.ngOnChanges({
|
||||||
|
sorting: new SimpleChange(null, sort, false)
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
const dataSort = dataTable.data.getSorting();
|
||||||
|
expect(dataSort).toEqual(dataSortObj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set custom sort order', () => {
|
||||||
|
const dataSortObj = new DataSorting('dummayName', 'asc');
|
||||||
|
|
||||||
|
const sort = [ 'dummayName', 'asc' ];
|
||||||
|
dataTable.data = new ObjectDataTableAdapter([],
|
||||||
|
[new ObjectDataColumn({ key: 'name' })]
|
||||||
|
);
|
||||||
|
dataTable.data.setSorting(new DataSorting('created', 'desc'));
|
||||||
|
dataTable.ngOnChanges({
|
||||||
|
sorting: new SimpleChange(null, sort, false)
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
const dataSort = dataTable.data.getSorting();
|
||||||
|
expect(dataSort).toEqual(dataSortObj);
|
||||||
|
});
|
||||||
|
|
||||||
it('should reset selection on mode change', () => {
|
it('should reset selection on mode change', () => {
|
||||||
spyOn(dataTable, 'resetSelection').and.callThrough();
|
spyOn(dataTable, 'resetSelection').and.callThrough();
|
||||||
|
|
||||||
|
@ -67,6 +67,12 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
@Input()
|
@Input()
|
||||||
rows: any[] = [];
|
rows: any[] = [];
|
||||||
|
|
||||||
|
/** Define the sort order of the datatable. Possible values are :
|
||||||
|
* [`created`, `desc`], [`created`, `asc`], [`due`, `desc`], [`due`, `asc`]
|
||||||
|
*/
|
||||||
|
@Input()
|
||||||
|
sorting: any[] = [];
|
||||||
|
|
||||||
/** Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode,
|
/** Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode,
|
||||||
* you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows.
|
* you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows.
|
||||||
*/
|
*/
|
||||||
@ -207,6 +213,10 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
this.resetSelection();
|
this.resetSelection();
|
||||||
this.emitRowSelectionEvent('row-unselect', null);
|
this.emitRowSelectionEvent('row-unselect', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isPropertyChanged(changes['sorting'])) {
|
||||||
|
this.setTableSorting(changes['sorting'].currentValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngDoCheck() {
|
ngDoCheck() {
|
||||||
@ -224,6 +234,12 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
return rows.map(row => new ObjectDataRow(row));
|
return rows.map(row => new ObjectDataRow(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertToDataSorting(sorting: any[]): DataSorting {
|
||||||
|
if (sorting && sorting.length > 0) {
|
||||||
|
return new DataSorting(sorting[0], sorting[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private initAndSubscribeClickStream() {
|
private initAndSubscribeClickStream() {
|
||||||
this.unsubscribeClickStream();
|
this.unsubscribeClickStream();
|
||||||
let singleClickStream = this.click$
|
let singleClickStream = this.click$
|
||||||
@ -300,6 +316,12 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setTableSorting(sorting) {
|
||||||
|
if (this.data) {
|
||||||
|
this.data.setSorting(this.convertToDataSorting(sorting));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onRowClick(row: DataRow, e: MouseEvent) {
|
onRowClick(row: DataRow, e: MouseEvent) {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<adf-datatable #dataTable
|
<adf-datatable #dataTable
|
||||||
[data]="data"
|
[data]="data"
|
||||||
|
[sorting]="dataSort"
|
||||||
[loading]="isLoading"
|
[loading]="isLoading"
|
||||||
[selectionMode]="selectionMode"
|
[selectionMode]="selectionMode"
|
||||||
[multiselect]="multiselect"
|
[multiselect]="multiselect"
|
||||||
|
@ -251,6 +251,12 @@ describe('ProcessInstanceListComponent', () => {
|
|||||||
expect(component.getCurrentId()).toBeNull();
|
expect(component.getCurrentId()).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the sorting order if sort is defined', () => {
|
||||||
|
component.sort = 'fakeKey-fakeOrder';
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.dataSort).toEqual(['fakeKey', 'fakeOrder']);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return selected true for the selected process', () => {
|
it('should return selected true for the selected process', () => {
|
||||||
component.data = new ObjectDataTableAdapter(
|
component.data = new ObjectDataTableAdapter(
|
||||||
[
|
[
|
||||||
|
@ -131,6 +131,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
currentInstanceId: string;
|
currentInstanceId: string;
|
||||||
isLoading: boolean = true;
|
isLoading: boolean = true;
|
||||||
layoutPresets = {};
|
layoutPresets = {};
|
||||||
|
sorting: any[] = ['created', 'desc'];
|
||||||
|
|
||||||
pagination: BehaviorSubject<PaginationModel>;
|
pagination: BehaviorSubject<PaginationModel>;
|
||||||
|
|
||||||
@ -289,6 +290,14 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort the process based on current value of 'sort' property
|
||||||
|
* Return the sorting order
|
||||||
|
*/
|
||||||
|
get dataSort(): any[] {
|
||||||
|
return this.sort ? this.sort.split('-') : this.sorting;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current id
|
* Return the current id
|
||||||
*/
|
*/
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<adf-datatable
|
<adf-datatable
|
||||||
[data]="data"
|
[data]="data"
|
||||||
|
[sorting]="dataSort"
|
||||||
[loading]="isLoading"
|
[loading]="isLoading"
|
||||||
[multiselect]="multiselect"
|
[multiselect]="multiselect"
|
||||||
[selectionMode]="selectionMode"
|
[selectionMode]="selectionMode"
|
||||||
|
@ -334,6 +334,12 @@ describe('TaskListComponent', () => {
|
|||||||
expect(component.getCurrentId()).toBeNull();
|
expect(component.getCurrentId()).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the sorting order if sort is defined', () => {
|
||||||
|
component.sort = 'fakeKey-fakeOrder';
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.dataSort).toEqual(['fakeKey', 'fakeOrder']);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return selected true for the selected task', () => {
|
it('should return selected true for the selected task', () => {
|
||||||
component.data = new ObjectDataTableAdapter(
|
component.data = new ObjectDataTableAdapter(
|
||||||
[
|
[
|
||||||
|
@ -136,6 +136,7 @@ export class TaskListComponent implements OnChanges, AfterContentInit, Paginated
|
|||||||
size: number = PaginationComponent.DEFAULT_PAGINATION.maxItems;
|
size: number = PaginationComponent.DEFAULT_PAGINATION.maxItems;
|
||||||
|
|
||||||
isLoading: boolean = true;
|
isLoading: boolean = true;
|
||||||
|
sorting: any[] = ['created', 'desc'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles custom data source mode.
|
* Toggles custom data source mode.
|
||||||
@ -301,6 +302,14 @@ export class TaskListComponent implements OnChanges, AfterContentInit, Paginated
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the sorting order
|
||||||
|
* Sort the tasks based on current value of 'sort' property
|
||||||
|
*/
|
||||||
|
get dataSort(): any[] {
|
||||||
|
return this.sort ? this.sort.split('-') : this.sorting;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current id
|
* Return the current id
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user