47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
class LocatorTable {
|
|
constructor($filter) {
|
|
this.$filter = $filter;
|
|
this.itemsDisplayedInList = 7;
|
|
this.pageTable = {
|
|
filter: {
|
|
page: 1,
|
|
size: this.itemsDisplayedInList
|
|
},
|
|
model: []
|
|
};
|
|
this._routes = [];
|
|
}
|
|
|
|
set routes(value) {
|
|
this._routes = value;
|
|
this.totalFilter = this._routes.length;
|
|
this.pageTable.filter.page = 1;
|
|
this.paginate();
|
|
}
|
|
get routes() {
|
|
return this._routes;
|
|
}
|
|
|
|
onOrder(field, order) {
|
|
let reverse = order === 'DESC';
|
|
this.routes = this.$filter('orderBy')(this.routes, field, reverse);
|
|
this.paginate();
|
|
}
|
|
paginate() {
|
|
let init = (this.pageTable.filter.page - 1) * this.itemsDisplayedInList;
|
|
let fin = this.pageTable.filter.page * this.itemsDisplayedInList;
|
|
this.pageTable.model = this.routes.slice(init, fin);
|
|
}
|
|
}
|
|
LocatorTable.$inject = ['$filter'];
|
|
|
|
ngModule.component('vnLocatorTable', {
|
|
template: require('./locator-table.html'),
|
|
bindings: {
|
|
routes: '<'
|
|
},
|
|
controller: LocatorTable
|
|
});
|