Commit f19a5fab2b12a009279515a4560eed00c430e2f9
Exists in
master
and in
2 other branches
Merge branch 'master' into 'develop'
Master(benjamin) See merge request !13
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaModalRemito') |
| 2 | - .controller('focaModalRemitoController', | |
| 2 | + .controller('focaModalRemitoController', | |
| 3 | 3 | [ |
| 4 | 4 | '$timeout', |
| 5 | 5 | '$filter', |
| ... | ... | @@ -8,13 +8,14 @@ angular.module('focaModalRemito') |
| 8 | 8 | 'focaModalRemitoService', |
| 9 | 9 | 'usadoPor', |
| 10 | 10 | 'focaModalService', |
| 11 | - function($timeout, $filter, $scope, $uibModalInstance, | |
| 11 | + function ($timeout, $filter, $scope, $uibModalInstance, | |
| 12 | 12 | focaModalRemitoService, usadoPor, focaModalService |
| 13 | 13 | ) { |
| 14 | 14 | var fecha = new Date(); |
| 15 | 15 | $scope.fechaHasta = new Date(); |
| 16 | 16 | $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); |
| 17 | - $scope.filters = ''; | |
| 17 | + $scope.filtersCliente = ''; | |
| 18 | + $scope.filtersRemito = ''; | |
| 18 | 19 | $scope.remitos = []; |
| 19 | 20 | $scope.isCollapsed = false; |
| 20 | 21 | $scope.verProductos = {}; |
| ... | ... | @@ -26,21 +27,21 @@ angular.module('focaModalRemito') |
| 26 | 27 | $scope.filteredRemitos = []; |
| 27 | 28 | $scope.currentPageRemitos = []; |
| 28 | 29 | $scope.selectedRemito = -1; |
| 29 | - | |
| 30 | + | |
| 30 | 31 | //METODOS |
| 31 | - $scope.busquedaPress = function(key) { | |
| 32 | + $scope.busquedaPress = function (key) { | |
| 32 | 33 | if (key === 13) { |
| 33 | - if(!$scope.fechaDesde) { | |
| 34 | + if (!$scope.fechaDesde) { | |
| 34 | 35 | focaModalService |
| 35 | 36 | .alert('INGRESE FECHA DESDE'); |
| 36 | 37 | return; |
| 37 | 38 | } |
| 38 | - if(!$scope.fechaHasta) { | |
| 39 | + if (!$scope.fechaHasta) { | |
| 39 | 40 | focaModalService |
| 40 | 41 | .alert('INGRESE FECHA HASTA'); |
| 41 | 42 | return; |
| 42 | 43 | } |
| 43 | - if($scope.fechaDesde > $scope.fechaHasta) { | |
| 44 | + if ($scope.fechaDesde > $scope.fechaHasta) { | |
| 44 | 45 | focaModalService |
| 45 | 46 | .alert('La fecha desde no puede ser mayor a la fecha hasta'); |
| 46 | 47 | return; |
| ... | ... | @@ -53,6 +54,7 @@ angular.module('focaModalRemito') |
| 53 | 54 | .then(llenarDatos); |
| 54 | 55 | } |
| 55 | 56 | }; |
| 57 | + | |
| 56 | 58 | function llenarDatos(res) { |
| 57 | 59 | $scope.remitos = []; |
| 58 | 60 | $scope.filteredRemitos = []; |
| ... | ... | @@ -64,17 +66,40 @@ angular.module('focaModalRemito') |
| 64 | 66 | $scope.search(true); |
| 65 | 67 | primera(); |
| 66 | 68 | } |
| 67 | - $scope.search = function(pressed) { | |
| 68 | - if($scope.remitos.length > 0) { | |
| 69 | + | |
| 70 | + $scope.searchRemito = function (pressed) { | |
| 71 | + if ($scope.remitos.length > 0) { | |
| 69 | 72 | $scope.filteredRemitos = $filter('filter')( |
| 70 | 73 | $scope.remitos, |
| 71 | - {$: $scope.filters} | |
| 74 | + { numeroRemito: $scope.filtersRemito } | |
| 72 | 75 | ); |
| 73 | 76 | |
| 74 | - if(pressed && $scope.filteredRemitos.length === 0){ | |
| 75 | - $timeout(function() { | |
| 77 | + if (pressed && $scope.filteredRemitos.length === 0) { | |
| 78 | + $timeout(function () { | |
| 76 | 79 | angular.element('#search')[0].focus(); |
| 77 | - $scope.filters = ''; | |
| 80 | + $scope.filtersRemito = ''; | |
| 81 | + }); | |
| 82 | + } | |
| 83 | + | |
| 84 | + $scope.lastPage = Math.ceil( | |
| 85 | + $scope.filteredRemitos.length / $scope.numPerPage | |
| 86 | + ); | |
| 87 | + | |
| 88 | + $scope.resetPage(); | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | + $scope.searchCliente = function (pressed) { | |
| 93 | + if ($scope.remitos.length > 0) { | |
| 94 | + $scope.filteredRemitos = $filter('filter')( | |
| 95 | + $scope.remitos, | |
| 96 | + { nombreCliente: $scope.filtersCliente } | |
| 97 | + ); | |
| 98 | + | |
| 99 | + if (pressed && $scope.filteredRemitos.length === 0) { | |
| 100 | + $timeout(function () { | |
| 101 | + angular.element('#search')[0].focus(); | |
| 102 | + $scope.filtersCliente = ''; | |
| 78 | 103 | }); |
| 79 | 104 | } |
| 80 | 105 | |
| ... | ... | @@ -86,12 +111,12 @@ angular.module('focaModalRemito') |
| 86 | 111 | } |
| 87 | 112 | }; |
| 88 | 113 | |
| 89 | - $scope.resetPage = function() { | |
| 114 | + $scope.resetPage = function () { | |
| 90 | 115 | $scope.currentPage = 1; |
| 91 | 116 | $scope.selectPage(1); |
| 92 | 117 | }; |
| 93 | 118 | |
| 94 | - $scope.selectPage = function(page) { | |
| 119 | + $scope.selectPage = function (page) { | |
| 95 | 120 | var start = (page - 1) * $scope.numPerPage; |
| 96 | 121 | var end = start + $scope.numPerPage; |
| 97 | 122 | $scope.paginas = []; |
| ... | ... | @@ -100,21 +125,21 @@ angular.module('focaModalRemito') |
| 100 | 125 | $scope.currentPage = page; |
| 101 | 126 | }; |
| 102 | 127 | |
| 103 | - $scope.select = function(remito) { | |
| 128 | + $scope.select = function (remito) { | |
| 104 | 129 | $uibModalInstance.close(remito); |
| 105 | 130 | }; |
| 106 | 131 | |
| 107 | - $scope.cancel = function() { | |
| 132 | + $scope.cancel = function () { | |
| 108 | 133 | $uibModalInstance.dismiss('cancel'); |
| 109 | 134 | }; |
| 110 | 135 | |
| 111 | - $scope.busquedaDown = function(key) { | |
| 136 | + $scope.busquedaDown = function (key) { | |
| 112 | 137 | if (key === 40) { |
| 113 | 138 | primera(key); |
| 114 | 139 | } |
| 115 | 140 | }; |
| 116 | 141 | |
| 117 | - $scope.itemRemito = function(key) { | |
| 142 | + $scope.itemRemito = function (key) { | |
| 118 | 143 | if (key === 38) { |
| 119 | 144 | anterior(key); |
| 120 | 145 | } |
| ... | ... | @@ -137,7 +162,7 @@ angular.module('focaModalRemito') |
| 137 | 162 | paginas.push(paginaActual); |
| 138 | 163 | |
| 139 | 164 | if (paginaActual - 1 > 1) { |
| 140 | - | |
| 165 | + | |
| 141 | 166 | paginas.unshift(paginaActual - 1); |
| 142 | 167 | if (paginaActual - 2 > 1) { |
| 143 | 168 | paginas.unshift(paginaActual - 2); |
| ... | ... | @@ -175,10 +200,10 @@ angular.module('focaModalRemito') |
| 175 | 200 | } |
| 176 | 201 | |
| 177 | 202 | function siguiente() { |
| 178 | - if ($scope.selectedRemito < $scope.currentPageRemitos.length - 1 ) { | |
| 203 | + if ($scope.selectedRemito < $scope.currentPageRemitos.length - 1) { | |
| 179 | 204 | $scope.selectedRemito++; |
| 180 | 205 | } else { |
| 181 | - avanzarPagina(); | |
| 206 | + avanzarPagina(); | |
| 182 | 207 | } |
| 183 | 208 | } |
| 184 | 209 |
src/views/foca-modal-remito.html
| ... | ... | @@ -4,13 +4,37 @@ |
| 4 | 4 | <h5 class="modal-title my-1">Búsqueda de Remito</h5> |
| 5 | 5 | </div> |
| 6 | 6 | <div class="input-group col-lg-6 pr-0 my-2"> |
| 7 | + <div class="mr-4"> | |
| 8 | + <input | |
| 9 | + ladda="searchLoading" | |
| 10 | + type="text" | |
| 11 | + class="form-control form-control-sm" | |
| 12 | + placeholder="CLIENTE" | |
| 13 | + ng-model="filtersCliente" | |
| 14 | + ng-change="searchCliente()" | |
| 15 | + ng-keydown="busquedaDown($event.keyCode)" | |
| 16 | + ng-keypress="busquedaPress($event.keyCode)" | |
| 17 | + foca-focus="selectedRemito == -1" | |
| 18 | + ng-focus="selectedRemito = -1" | |
| 19 | + id="search" | |
| 20 | + teclado-virtual | |
| 21 | + > | |
| 22 | + <button | |
| 23 | + ng-show="filtersCliente.length >= 1" | |
| 24 | + type="button" | |
| 25 | + class="clear-input" | |
| 26 | + ng-click="filtersCliente = ''" | |
| 27 | + > | |
| 28 | + <i class="fa fa-times"></i> | |
| 29 | + </button> | |
| 30 | + </div> | |
| 7 | 31 | <input |
| 8 | 32 | ladda="searchLoading" |
| 9 | 33 | type="text" |
| 10 | 34 | class="form-control form-control-sm" |
| 11 | - placeholder="Razón social" | |
| 12 | - ng-model="filters" | |
| 13 | - ng-change="search()" | |
| 35 | + placeholder="REMITO" | |
| 36 | + ng-model="filtersRemito" | |
| 37 | + ng-change="searchRemito()" | |
| 14 | 38 | ng-keydown="busquedaDown($event.keyCode)" |
| 15 | 39 | ng-keypress="busquedaPress($event.keyCode)" |
| 16 | 40 | foca-focus="selectedRemito == -1" |
| ... | ... | @@ -19,13 +43,13 @@ |
| 19 | 43 | teclado-virtual |
| 20 | 44 | > |
| 21 | 45 | <button |
| 22 | - ng-show="filters.length >= 1" | |
| 46 | + ng-show="filtersRemito.length >= 1" | |
| 23 | 47 | type="button" |
| 24 | 48 | class="clear-input" |
| 25 | - ng-click="filters = ''" | |
| 49 | + ng-click="filtersRemito = ''" | |
| 26 | 50 | > |
| 27 | 51 | <i class="fa fa-times"></i> |
| 28 | - </button> | |
| 52 | + </button> | |
| 29 | 53 | <div class="input-group-append"> |
| 30 | 54 | <button |
| 31 | 55 | ladda="searchLoading" |
| ... | ... | @@ -39,7 +63,6 @@ |
| 39 | 63 | </div> |
| 40 | 64 | </div> |
| 41 | 65 | </div> |
| 42 | - | |
| 43 | 66 | </div> |
| 44 | 67 | <div class="modal-body" id="modal-body"> |
| 45 | 68 | <div class="input-group row"> |