Integrating datatable into document list (wip)

This commit is contained in:
Denys Vuika
2016-07-05 09:30:28 +01:00
parent b02a465f27
commit e3924fdaa3
7 changed files with 320 additions and 18 deletions

View File

@@ -29,7 +29,8 @@ import {
DataTableAdapter,
DataRow,
DataColumn,
DataSorting
DataSorting,
DataRowEvent
} from './../data/datatable-adapter';
import { ObjectDataTableAdapter } from '../data/object-datatable-adapter';
@@ -54,10 +55,10 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
actions: boolean = false;
@Output()
rowClick: EventEmitter<any> = new EventEmitter();
rowClick: EventEmitter<DataRowEvent> = new EventEmitter();
@Output()
rowDblClick: EventEmitter<any> = new EventEmitter();
rowDblClick: EventEmitter<DataRowEvent> = new EventEmitter();
isSelectAllChecked: boolean = false;
@@ -84,7 +85,8 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
}
this.rowClick.emit({
value: row
value: row,
event: e
});
}
@@ -94,7 +96,8 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
}
this.rowDblClick.emit({
value: row
value: row,
event: e
});
}
@@ -134,14 +137,16 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
isIconValue(row: DataRow, col: DataColumn) {
if (row && col) {
return row.getValue(col.key).startsWith('material-icons://');
let value = row.getValue(col.key);
return value && value.startsWith('material-icons://');
}
return false;
}
asIconValue(row: DataRow, col: DataColumn) {
if (this.isIconValue(row, col)) {
return row.getValue(col.key).replace('material-icons://', '');
let value = row.getValue(col.key) || '';
return value.replace('material-icons://', '');
}
return null;
}

View File

@@ -16,7 +16,6 @@
*/
export interface DataTableAdapter {
getRows(): Array<DataRow>;
setRows(rows: Array<DataRow>): void;
getColumns(): Array<DataColumn>;
@@ -25,19 +24,15 @@ export interface DataTableAdapter {
getSorting(): DataSorting;
setSorting(sorting: DataSorting): void;
sort(key?: string, direction?: string): void;
}
export interface DataRow {
isSelected: boolean;
hasValue(key: string): boolean;
getValue(key: string): any;
}
export interface DataColumn {
key: string;
type: string; // text|image|date
format?: string;
@@ -45,14 +40,16 @@ export interface DataColumn {
title?: string;
srTitle?: string;
cssClass?: string;
}
export class DataSorting {
constructor(
public key?: string,
public direction?: string) {
}
}
export interface DataRowEvent {
value?: DataRow;
event: Event;
}