diff --git a/src/js/controller.js b/src/js/controller.js index 9a51a78..18aedd0 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -4,14 +4,6 @@ angular.module('focaAbmPreciosCondiciones') 'focaModalService', 'focaBotoneraLateralService', '$timeout', function($scope, focaAbmPreciosCondicionesService, $location, focaModalService, focaBotoneraLateralService, $timeout) { - focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { - $scope.preciosCondiciones = datos.data; - $scope.preciosCondiciones.forEach(function(precioCondicion) { - precioCondicion.plazoPago.sort(function(a, b) { - return a.dias- b.dias; - }); - }); - }); $timeout(function() { focaBotoneraLateralService.showSalir(true); @@ -19,7 +11,7 @@ angular.module('focaAbmPreciosCondiciones') focaBotoneraLateralService.showCancelar(false); focaBotoneraLateralService.showGuardar(false); }); - + $scope.filters = ''; $scope.now = new Date(); $scope.editar = function(id) { $location.path('/precio-condicion/' + id); @@ -38,6 +30,21 @@ angular.module('focaAbmPreciosCondiciones') } ); }; + + $scope.buscar = function(key) { + if(key === 13){ + focaAbmPreciosCondicionesService + .obtenerPreciosCondiciones($scope.filters) + .then(function(datos) { + $scope.preciosCondiciones = datos.data; + $scope.preciosCondiciones.forEach(function(precioCondicion) { + precioCondicion.plazoPago.sort(function(a, b) { + return a.dias- b.dias; + }); + }); + }); + } + }; } ]) .controller('focaAbmPrecioCondicionController', [ @@ -47,6 +54,7 @@ angular.module('focaAbmPreciosCondiciones') $scope, focaAbmPreciosCondicionesService, focaBotoneraLateralService, $routeParams, $location, focaModalService, $timeout, $uibModal, $window ) { + $scope.focused = 1; $scope.plazosAEliminar = []; $scope.mostrarPlazos = $routeParams.id > 0; $scope.now = new Date(); @@ -168,19 +176,26 @@ angular.module('focaAbmPreciosCondiciones') ); }; - $scope.seleccionarListaPrecio = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Listas de precio', - templateUrl: 'modal-lista-precio.html', - controller: 'focaModalListaPrecioCtrl', - size: 'lg' - } - ); - modalInstance.result.then(function(listaPrecio) { - $scope.precioCondicion.listaPrecio = listaPrecio; - $scope.listaPrecioLabel = listaPrecio.ID + ' - ' + listaPrecio.DES; - }); + $scope.seleccionarListaPrecio = function(key) { + if(key === 13){ + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Listas de precio', + templateUrl: 'modal-lista-precio.html', + controller: 'focaModalListaPrecioCtrl', + size: 'lg' + } + ); + modalInstance.result.then(function(listaPrecio) { + $scope.precioCondicion.listaPrecio = listaPrecio; + $scope.listaPrecioLabel = listaPrecio.ID + ' - ' + listaPrecio.DES; + $scope.focused = 4; + }); + } + }; + + $scope.next = function(key) { + if(key === 13) $scope.focused++; }; } ]); diff --git a/src/js/service.js b/src/js/service.js index 8ec5eea..9172b1b 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -3,8 +3,8 @@ angular.module('focaAbmPreciosCondiciones') '$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { return { - obtenerPreciosCondiciones: function() { - return $http.get(API_ENDPOINT.URL + '/precio-condicion'); + obtenerPreciosCondiciones: function(nombre) { + return $http.post(API_ENDPOINT.URL + '/precios-condiciones', {nombre: nombre}); }, obtenerPrecioCondicion: function(id) { return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); diff --git a/src/views/foca-abm-precios-condiciones-item.html b/src/views/foca-abm-precios-condiciones-item.html index e4e637b..768fe72 100644 --- a/src/views/foca-abm-precios-condiciones-item.html +++ b/src/views/foca-abm-precios-condiciones-item.html @@ -25,6 +25,9 @@ name="nombre" ng-model="precioCondicion.nombre" autocomplete="off" + foca-focus="focused == 1" + ng-focus="focused = 1" + ng-keypress="next($event.keyCode)" teclado-virtual /> @@ -36,6 +39,9 @@ name="nombre" ng-model="precioCondicion.descripcion" autocomplete="off" + foca-focus="focused == 2" + ng-focus="focused = 2" + ng-keypress="next($event.keyCode)" teclado-virtual /> @@ -45,6 +51,9 @@
@@ -53,8 +62,7 @@ class="btn btn-outline-secondary form-control" title="Buscar" type="button" - ng-click="seleccionarListaPrecio()" - foca-focus="focused == 3" + ng-click="seleccionarListaPrecio(13)" > @@ -69,7 +77,8 @@ min="0" ng-model="plazoACargar.dias" ng-keypress="agregarPlazo($event.keyCode)" - foca-focus="ingreso" + foca-focus="focused == 4" + ng-focus="focused = 4" placeholder="Días" />
@@ -78,7 +87,6 @@ title="Agregar" type="button" ng-click="agregarPlazo(13)" - foca-focus="focused == 3" > diff --git a/src/views/foca-abm-precios-condiciones-listado.html b/src/views/foca-abm-precios-condiciones-listado.html index 128abe6..1394da3 100644 --- a/src/views/foca-abm-precios-condiciones-listado.html +++ b/src/views/foca-abm-precios-condiciones-listado.html @@ -14,7 +14,7 @@ id="search" placeholder="Búsqueda" teclado-virtual - ng-keypress="busquedaPress($event.keyCode)" + ng-keypress="buscar($event.keyCode)" ng-model="filters" />
@@ -22,7 +22,7 @@ ladda="searchLoading" class="btn btn-outline-secondary" type="button" - ng-click="busquedaPress(13)" + ng-click="buscar(13)" > @@ -46,7 +46,7 @@ - +