[ADF-1364] Infinite scrolling for Copy & Move (#2362)

* Use infinite pagination for search also
* Fix highlight in copy & move
* Fix highlight and material menu issue
* Update documentation
This commit is contained in:
Popovics András
2017-09-21 14:34:31 +01:00
committed by Eugenio Romano
parent b28a5b2a69
commit 2d6c8f92f0
29 changed files with 2598 additions and 4276 deletions

View File

@@ -23,7 +23,7 @@ import { DataColumn, DataRow, DataTableAdapter } from '../../data/datatable-adap
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container>
<span [title]="tooltip">{{value}}</span>
<span [title]="tooltip" class="adf-datatable-cell-value">{{value}}</span>
</ng-container>`,
encapsulation: ViewEncapsulation.None,
host: { class: 'adf-datatable-cell' }

View File

@@ -631,4 +631,31 @@ describe('DataTable', () => {
expect(dataTable.getCellTooltip(row, col)).toBeNull();
});
it('should cache the rows menu', () => {
let emitted = 0;
dataTable.showRowActionsMenu.subscribe(() => { emitted++; });
const column = <DataColumn> {};
const row = <DataRow> { getValue: function (key: string) { return 'id'; } };
dataTable.getRowActions(row, column);
dataTable.getRowActions(row, column);
dataTable.getRowActions(row, column);
expect(emitted).toBe(1);
});
it('should reset the menu cache after rows change', () => {
let emitted = 0;
dataTable.showRowActionsMenu.subscribe(() => { emitted++; });
const column = <DataColumn> {};
const row = <DataRow> { getValue: function (key: string) { return 'id'; } };
dataTable.getRowActions(row, column);
dataTable.ngOnChanges({'data': new SimpleChange('123', {}, true)});
dataTable.getRowActions(row, column);
expect(emitted).toBe(2);
});
});

View File

@@ -102,6 +102,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
private schema: DataColumn[] = [];
private differ: any;
private rowMenuCache: object = {};
private singleClickStreamSub: Subscription;
private multiClickStreamSub: Subscription;
@@ -208,6 +209,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
private initTable() {
this.data = new ObjectDataTableAdapter(this.rows, this.schema);
this.rowMenuCache = {};
}
isTableEmpty() {
@@ -375,9 +377,15 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
}
getRowActions(row: DataRow, col: DataColumn): any[] {
let event = new DataCellEvent(row, col, []);
this.showRowActionsMenu.emit(event);
return event.value.actions;
const id = row.getValue('id');
if (!this.rowMenuCache[id]) {
let event = new DataCellEvent(row, col, []);
this.showRowActionsMenu.emit(event);
this.rowMenuCache[id] = event.value.actions;
}
return this.rowMenuCache[id];
}
onExecuteRowAction(row: DataRow, action: any) {