diff --git a/client/core/src/column-header/column-header.js b/client/core/src/column-header/column-header.js index b153f0987..4de066bcc 100644 --- a/client/core/src/column-header/column-header.js +++ b/client/core/src/column-header/column-header.js @@ -1,7 +1,8 @@ import {module} from '../module'; export default class ColumnHeader { - constructor() { + constructor($attrs) { + this.$attrs = $attrs; this.order = undefined; this.mouseIsOver = false; } @@ -21,8 +22,14 @@ export default class ColumnHeader { } return showArrow; } + $onInit() { + if (this.$attrs.defaultOrder) { + this.order = this.$attrs.defaultOrder; + this.onClick(); + } + } } -ColumnHeader.$inject = []; +ColumnHeader.$inject = ['$attrs']; module.component('vnColumnHeader', { template: require('./column-header.html'), diff --git a/client/core/src/multi-check/multi-check.js b/client/core/src/multi-check/multi-check.js index 565788a6a..4ab7c87ce 100644 --- a/client/core/src/multi-check/multi-check.js +++ b/client/core/src/multi-check/multi-check.js @@ -64,12 +64,12 @@ export default class MultiCheck { if (this.type.id && this.type.id !== 'all' && this.type.id !== 'any') { if (this.type.id.length > 3 && this.type.id.substr(0, 3) === 'no-') { let label = this.type.id.replace('no-', ''); - checked = el[label] == null; + checked = Boolean(el[label]) === false; } else if (this.type.id.length > 6 && this.type.id.substr(0, 6) === 'equal-') { let label = this.type.id.replace('equal-', ''); checked = (el[label] && el[label] === this.type.name); } else { - checked = el[this.type.id] != null; + checked = Boolean(el[this.type.id]) === true; } } else { checked = this.checkAll === 1; diff --git a/client/locator/src/index/index.js b/client/locator/src/index/index.js index e7ad4e98b..87871ef1c 100644 --- a/client/locator/src/index/index.js +++ b/client/locator/src/index/index.js @@ -3,10 +3,26 @@ import ngModule from '../module'; class LocatorIndex { constructor($state) { this.$state = $state; - this.routes = [ - {id: 1, zoneFk: 1, postalcode: 46006, order: 1, preparado: '25/08', entrada: '26/08', ticket: 1547892, routeFk: 9999, alias: 'Flores Vendrell', bultos: 12, m3: 0.23}, - {id: 2, zoneFk: 1, postalcode: 46006, order: 1, preparado: '25/08', entrada: '26/08', ticket: 1547892, routeFk: 9999, alias: 'Flores Vendrell', bultos: 12, m3: 0.23} - ]; + this.routes = []; + + for (let i = 1; i < 100; i++) { + this.routes.push( + { + id: i, + zoneFk: Math.floor(Math.random() * 6) + 1, + postalcode: 46006, + order: Math.floor(Math.random() * 3) + 1, + preparado: '25/08', + entrada: '26/08', + ticket: 1547890 + i, + routeFk: Math.floor(Math.random() * 9999) + 1000, + alias: `Flores X${Math.floor(Math.random() * 3) + 1}`, + bultos: Math.floor(Math.random() * 20) + 10, + m3: (Math.random()).toFixed(2), + error: (Math.floor(Math.random() * 3) + 1) === 1 + } + ); + } } } LocatorIndex.$inject = ['$state']; diff --git a/client/locator/src/locale/es.json b/client/locator/src/locale/es.json index 0d047d05d..e1ac63778 100644 --- a/client/locator/src/locale/es.json +++ b/client/locator/src/locale/es.json @@ -1,5 +1,6 @@ { "Routes locator": "Localizador de rutas", "Filter": "Filtro", - "Store": "Almacén" + "Store": "Almacén", + "Address": "Dirección" } \ No newline at end of file diff --git a/client/locator/src/locator-table/locator-table.html b/client/locator/src/locator-table/locator-table.html index b07a01c5d..d02f4525f 100644 --- a/client/locator/src/locator-table/locator-table.html +++ b/client/locator/src/locator-table/locator-table.html @@ -1,41 +1,54 @@ - - + + - - - - - - - - - - + + + + + + + + + + - - + + - - {{::route.zoneFk}} - {{::route.postalcode}} - {{::route.order}} - {{::route.preparado}} - {{::route.entrada}} - {{::route.ticket}} - {{::route.routeFk}} - {{::route.alias}} - {{::route.bultos}} - {{::route.m3}} + + {{::route.zoneFk}} + {{::route.postalcode}} + {{::route.order}} + {{::route.preparado}} + {{::route.entrada}} + {{::route.ticket}} + {{::route.routeFk}} + {{::route.alias}} + {{::route.bultos}} + {{::route.m3}} - + - - - Direccion: + + + + Address: {{::route.address}} + + + + \ No newline at end of file diff --git a/client/locator/src/locator-table/locator-table.js b/client/locator/src/locator-table/locator-table.js index 3abe5f3d4..2b8834a65 100644 --- a/client/locator/src/locator-table/locator-table.js +++ b/client/locator/src/locator-table/locator-table.js @@ -1,11 +1,41 @@ import ngModule from '../module'; class LocatorTable { - constructor($state) { - this.$state = $state; + 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 = ['$state']; +LocatorTable.$inject = ['$filter']; ngModule.component('vnLocatorTable', { template: require('./locator-table.html'),