salix/client/locator/src/locator-table/locator-table.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-11-02 13:10:28 +00:00
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);
2017-11-02 13:10:28 +00:00
}
}
LocatorTable.$inject = ['$filter'];
2017-11-02 13:10:28 +00:00
ngModule.component('vnLocatorTable', {
template: require('./locator-table.html'),
2017-11-02 13:57:36 +00:00
bindings: {
routes: '<'
},
2017-11-02 13:10:28 +00:00
controller: LocatorTable
});