[WIP] CORD-686 Added pagination to table
Change-Id: I26c57cdf9759363e2bce2fd5333f45d63694278b
diff --git a/src/app/core/table/table.ts b/src/app/core/table/table.ts
index 1ed258d..2c0b272 100644
--- a/src/app/core/table/table.ts
+++ b/src/app/core/table/table.ts
@@ -19,6 +19,7 @@
type?: string; // understand why enum does not work
formatter?(item: any): string;
link?(item: any): string;
+ hover?(item: any): string;
}
interface IXosTableCgfOrder {
@@ -28,6 +29,9 @@
export interface IXosTableCfg {
columns: any[];
+ pagination?: {
+ pageSize: number;
+ };
order?: IXosTableCgfOrder;
filter?: string;
actions?: any[]; // TODO create interface
@@ -41,6 +45,7 @@
public reverse: boolean;
public classes: string;
private config: IXosTableCfg;
+ private currentPage: number;
$onInit() {
@@ -94,9 +99,28 @@
});
}
+ // if an hover property is passed,
+ // it should be a function
+ let hoverColumns = _.filter(this.config.columns, col => angular.isDefined(col.hover));
+ if (angular.isArray(hoverColumns) && hoverColumns.length > 0) {
+ _.forEach(hoverColumns, (col) => {
+ if (!angular.isFunction(col.hover)) {
+ throw new Error('[xosTable] The hover property should be a function.');
+ }
+ });
+ }
+
+ if (this.config.pagination) {
+ this.currentPage = 0;
+ }
+
this.columns = this.config.columns;
}
+
+ public goToPage = (n) => {
+ this.currentPage = n;
+ };
}
export const xosTable: angular.IComponentOptions = {