From 2bdbda6192906087a3083c670d5e639013e50cfe Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Thu, 22 Jun 2017 12:03:01 +0200 Subject: [PATCH] =?UTF-8?q?Localizador,=20cambio=20estlios,=20a=C3=B1adido?= =?UTF-8?q?=20paginador,=20order=20by?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/core/src/drop-down/drop-down.html | 20 ++++-- client/core/src/drop-down/drop-down.js | 11 ++- client/core/src/drop-down/style.scss | 60 ++++++++-------- client/core/src/icon-menu/icon-menu.html | 2 +- client/core/src/icon-menu/icon-menu.js | 3 + client/core/src/paging/paging.js | 10 ++- client/production/src/index/index.html | 38 +++++----- client/production/src/index/index.js | 71 ++++++++++++------- client/production/src/index/style.scss | 2 + .../src/components/main-menu/main-menu.html | 2 +- client/salix/src/styles/misc.scss | 20 ++++++ 11 files changed, 154 insertions(+), 85 deletions(-) diff --git a/client/core/src/drop-down/drop-down.html b/client/core/src/drop-down/drop-down.html index 59d312a6e..5c68ca3d2 100644 --- a/client/core/src/drop-down/drop-down.html +++ b/client/core/src/drop-down/drop-down.html @@ -1,7 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file diff --git a/client/core/src/drop-down/drop-down.js b/client/core/src/drop-down/drop-down.js index de7f6f648..f2a138d73 100644 --- a/client/core/src/drop-down/drop-down.js +++ b/client/core/src/drop-down/drop-down.js @@ -2,16 +2,23 @@ import {module} from '../module'; import './style.scss'; export default class DropDown { - constructor($element, $window) { + constructor($element, $scope) { this.$element = $element; + this.$ = $scope; } $onChanges(changesObj) { if (changesObj.show && changesObj.top && changesObj.top.currentValue) { this.$element.css('top', changesObj.top.currentValue + 'px'); } } + clearSearch() { + this.$.search = ''; + } + $onInit() { + this.clearSearch(); + } } -DropDown.$inject = ['$element']; +DropDown.$inject = ['$element', '$scope']; module.component('vnDropDown', { template: require('./drop-down.html'), diff --git a/client/core/src/drop-down/style.scss b/client/core/src/drop-down/style.scss index 70e5a43fb..85dbf7bbd 100644 --- a/client/core/src/drop-down/style.scss +++ b/client/core/src/drop-down/style.scss @@ -4,41 +4,41 @@ vn-drop-down { padding: 0 15px; margin-left: -15px; background: transparent; - ul{ - padding: 0; - margin: 10px 0 0 0; + .dropdown-body{ background: white; border: 1px solid #A7A7A7; - li { - list-style-type: none; - padding: 5px 10px; - cursor: pointer; - white-space: nowrap; - &.filter{ - padding: 5px; - input{ - height: 25px; - padding-left: 5px; - } - vn-icon{ - font-size: 16px; - position: absolute; - margin-left: -20px; - margin-top: 7px; + .filter{ + padding: 5px 9px 5px 5px; + input{ + height: 25px; + padding-left: 5px; + } + vn-icon{ + font-size: 16px; + margin-left: -20px; + margin-top: 7px; + cursor: pointer; + &:hover{ + color: red; } } } - li:hover{ - background-color: #3D3A3B; - color: white; - &.filter{ - vn-icon{ - color: #3D3A3B; - &:hover{ - color: red; - } - } + ul{ + padding: 0; + margin: 0; + background: white; + max-height: 400px; + overflow-y: auto; + li { + list-style-type: none; + padding: 5px 10px; + cursor: pointer; + white-space: nowrap; + } + li:hover{ + background-color: #3D3A3B; + color: white; } } - } + } } \ No newline at end of file diff --git a/client/core/src/icon-menu/icon-menu.html b/client/core/src/icon-menu/icon-menu.html index 4c49c44f6..a48aac3d2 100644 --- a/client/core/src/icon-menu/icon-menu.html +++ b/client/core/src/icon-menu/icon-menu.html @@ -1,4 +1,4 @@ -
+
\ No newline at end of file diff --git a/client/core/src/icon-menu/icon-menu.js b/client/core/src/icon-menu/icon-menu.js index 766b41247..b2a86827d 100644 --- a/client/core/src/icon-menu/icon-menu.js +++ b/client/core/src/icon-menu/icon-menu.js @@ -14,6 +14,9 @@ export default class IconMenu { set showDropDown(value) { this._showDropDown = value; } + show() { + // this._showDropDown = true; + } getItems() { this.$http.get(this.url).then( diff --git a/client/core/src/paging/paging.js b/client/core/src/paging/paging.js index 8e0b86aa1..e04f9ee5e 100644 --- a/client/core/src/paging/paging.js +++ b/client/core/src/paging/paging.js @@ -16,7 +16,8 @@ export default class Paging { $onChanges(changes) { if (!this.index) return; this.numPerPage = this.index.filter.size; - if(changes.total) + this.currentPage = this.index.filter.page; + if (changes.total) this.numItems = changes.total.currentValue; } onModelUpdated() { @@ -29,7 +30,11 @@ export default class Paging { } onPageChange(page) { this.index.filter.page = page; - this.index.accept(); + if (typeof this.pageChange === 'undefined') { + this.index.accept(); + } else { + this.pageChange(); + } } } Paging.$inject = ['$http', '$scope']; @@ -39,6 +44,7 @@ export const COMPONENT = { template: require('./paging.html'), bindings: { index: '<', + pageChange: '&?', total: '<' }, controller: Paging diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index 949875d96..c28ccd1e7 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -1,5 +1,3 @@ - - @@ -20,11 +18,14 @@ icon="keyboard_arrow_down" ng-click="$ctrl.moreFilters($event)"> - + @@ -59,29 +60,29 @@ - - + + - + - + - + - {{::ticket.ticket}} - {{::ticket.agency}} - {{::ticket.salePerson | ucwords}} + {{::ticket.ticketFk}} + {{::ticket.agency.name}} + {{::ticket.salesPerson.name | ucwords}} {{::ticket.salesPerson.surname | ucwords}} {{::ticket.hour}} - {{ticket.state}} + {{ticket.state.name}} {{::ticket.lines}} {{::ticket.m3}} {{::ticket.boxes}} @@ -89,18 +90,21 @@ - + - + : - {{$ctrl.tickets.length}} + {{$ctrl.totalFilter}} - {{$ctrl.lines}} - {{$ctrl.meters}} + {{$ctrl.lines}} + {{$ctrl.meters}} + + + \ No newline at end of file diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index f4c1e939f..2288e431d 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -9,13 +9,21 @@ export default class ProductionIndex { this.vnPopover = vnPopover; this.vnApp = vnApp; this.$translate = $translate; - + this.fakeIndex = { + filter: { + page: 1, + size: 14 + } + }; + this.order = {}; this.filter = {}; + this.order = {}; this._checkAll = false; this.tickets = []; this.states = []; this.lines = 0; this.meters = 0; + this.totalFilter = 0; this.actions = { state: null, worker: null, @@ -46,11 +54,11 @@ export default class ProductionIndex { } // Actions Callbacks _changeState(ids, sateteId, stateName, index) { - this.$http.put(`/production/api/TicketStates/[${ids}]/${sateteId}/changeState`).then( + this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, ids).then( () => { index.forEach( val => { - this.tickets[val].state = this.actions.state.name; + this.tickets[val].state = stateName; } ); } @@ -67,7 +75,7 @@ export default class ProductionIndex { let index = []; checks.forEach( (_, i) => { - ids.push(this.tickets[i].ticket); + ids.push(this.tickets[i].id); index.push(i); } ); @@ -83,18 +91,7 @@ export default class ProductionIndex { this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!')); } } - sumTickets() { - let lines = 0; - let meters = 0; - this.tickets.forEach( - val => { - lines += parseFloat(val.lines); - meters += parseFloat(val.m3); - } - ); - this.lines = lines; - this.meters = meters.toFixed(2); - } + // Start modals and actions modals _openComment(ids) { this.child = this.vnPopover.showComponent('vn-production-comment', this.$, this.$element[0].querySelector('.actionPanel')); @@ -109,17 +106,10 @@ export default class ProductionIndex { childCtrl.filter = Object.assign({}, this.filter); childCtrl.onSubmit = filter => this.onChildSubmit(filter); childCtrl.onCancel = () => this.onChildCancel(); - event.preventDefault(); } - onSearch(filter) { - let filters = filter || this.filter; - /* this.$.index.filter = filters; - this.$.index.accept(); */ - console.log('TODO: search with filters', filters); - } onChildSubmit(filter) { - this.onSearch(filter); + this.filterTickets(filter); this.onChildCancel(); } onChildComment(ids, comment) { @@ -132,8 +122,38 @@ export default class ProductionIndex { delete this.child; } // END modals and actions modals + searchTickets() { + let filters = Object.assign({}, { + where: this.filter + }, { + page: this.fakeIndex.filter.page, + limit: this.fakeIndex.filter.size + }); + if (this.order.field) { + filters.order = this.order.field + ' ' + this.order.dir; + } + this.$http.get('/production/api/FakeProductions/list?filter=' + JSON.stringify(filters)).then( + json => { + this.tickets = json.data.tickets; + this.lines = json.data.lines; + this.meters = json.data.m3; + this.totalFilter = json.data.total; + this.fakeIndex.model = json.data.tickets; + } + ); + } + filterTickets(filter) { + if (filter) { + this.filter = Object.assign({}, this.filter, filter); + } + this.order = {field: null, dir: null}; + this.fakeIndex.filter.page = 1; + this.fakeIndex.model = []; + this.searchTickets(); + } onOrder(field, dir) { - console.log('TODO: call rest api order by', field, dir); + this.order = {field: field, dir: dir}; + this.searchTickets(); } $doCheck() { if (this.actions.state) { @@ -150,6 +170,7 @@ export default class ProductionIndex { hour += ':00'; this.hourItems.push({id: i, name: hour}); } + this.filterTickets(); } } ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover', 'vnApp', '$translate']; diff --git a/client/production/src/index/style.scss b/client/production/src/index/style.scss index 292a6fbb7..eea97e50e 100644 --- a/client/production/src/index/style.scss +++ b/client/production/src/index/style.scss @@ -1,4 +1,6 @@ vn-production-index { + flex: 1; + button { height: 20px; padding: 0 6px; diff --git a/client/salix/src/components/main-menu/main-menu.html b/client/salix/src/components/main-menu/main-menu.html index 7902c4b72..075b91ef7 100644 --- a/client/salix/src/components/main-menu/main-menu.html +++ b/client/salix/src/components/main-menu/main-menu.html @@ -6,7 +6,7 @@