diff --git a/src/js/controller.js b/src/js/controller.js index 18b30ac..cb17e39 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -4,20 +4,86 @@ angular.module('focaModalCheque') '$filter', '$scope', '$uibModalInstance', - 'focaModalChequeService', - function($filter, $scope, $uibModalInstance, focaModalChequeService) { - focaModalChequeService.getBancos().then(function(res) { - $scope.bancos = res.data; - }); - focaModalChequeService.getProvincias().then(function(res) { - $scope.provincias = res.data; - }); - focaModalChequeService.getVendedores().then(function(res) { - $scope.vendedores = res.data; - }); + '$uibModal', + function($filter, $scope, $uibModalInstance, $uibModal) { + $scope.cheque = { + banco: '', + provincia: '' + }; + + $scope.seleccionarBanco = function(key) { + if(key === 13) { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Bancos', + templateUrl: 'modal-bancos.html', + controller: 'focaModalBancoController', + size: 'md', + resolve: {filters: function() {return $scope.cheque.banco;}} + } + ); + modalInstance.result.then(function(banco) { + $scope.cheque.banco = (banco.ID + ' ' + banco.desbco).trim(); + }, function() { + //TODO: función llamada cuando cancela el modal + }); + } + }; + + $scope.seleccionarProvincia = function(key) { + if(key === 13) { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Provincias', + templateUrl: 'modal-provincias.html', + controller: 'focaModalProvinciaController', + size: 'md', + resolve: {filters: function() {return $scope.cheque.provincia;}} + } + ); + modalInstance.result.then(function(provincia) { + $scope.cheque.provincia = (provincia.ID + + ' ' + provincia.NOMBRE).trim(); + $scope.cheque.idProvincia = provincia.ID; + }, function() { + //TODO: función llamada cuando cancela el modal + }); + } + }; + + $scope.seleccionarLocalidad = function(key) { + if(!$scope.cheque.idProvincia) { + //TODO: Poner modal alert de foca + alert('Seleccione una provincia'); + return; + } + if(key === 13) { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Localidades', + templateUrl: 'modal-localidades.html', + controller: 'focaModalLocalidadController', + size: 'md', + resolve: { + filters: { + idProvincia: $scope.cheque.idProvincia, + busqueda: $scope.cheque.localidad + } + } + } + ); + modalInstance.result.then(function(localidad) { + $scope.cheque.localidad = (localidad.ID + + ' ' + localidad.NOMBRE).trim(); + }, function() { + //TODO: función llamada cuando cancela el modal + }); + } + }; $scope.aceptar = function() { delete $scope.cheque.provincia.localidades; + //TODO: al enviar el importe con punto se pone como mil, no como decimal $scope.cheque.importe = parseFloat($scope.cheque.importe); $uibModalInstance.close($scope.cheque); }; diff --git a/src/js/service.js b/src/js/service.js deleted file mode 100644 index 8917b4c..0000000 --- a/src/js/service.js +++ /dev/null @@ -1,18 +0,0 @@ -angular.module('focaModalCheque') - .factory('focaModalChequeService', [ - '$http', - 'API_ENDPOINT', - function($http, API_ENDPOINT) { - return { - getBancos: function() { - return $http.get(API_ENDPOINT.URL + '/banco'); - }, - getProvincias: function() { - return $http.get(API_ENDPOINT.URL + '/provincia'); - }, - getVendedores: function() { - return $http.post(API_ENDPOINT.URL + '/vendedores', {nombre:''} ) - } - }; - } - ]); diff --git a/src/views/modal-cheque.html b/src/views/modal-cheque.html index b449e6a..48d974a 100644 --- a/src/views/modal-cheque.html +++ b/src/views/modal-cheque.html @@ -7,61 +7,90 @@
-
+
+
+ +
- +
-
+
+ placeholder="Nombre o Código de Provincia " + ng-model="cheque.provincia" + ng-required="true" + ng-keypress="seleccionarProvincia($event.keyCode)"/> +
+ +
-
- +
+
-
+
+ ng-keypress="seleccionarLocalidad($event.keyCode)"/> +
+ +
- +
-
+
+ placeholder="Librador" + ng-model="cheque.librador" + ng-required="true"/>
-
+
-
+
$
@@ -81,7 +110,10 @@ placeholder="Importe" ng-model="cheque.importe" ng-required="true"/> -
+
+
+ +
@@ -92,21 +124,24 @@ type="date" class="form-control form-control-sm" placeholder="Fecha" - ng-model="cheque.fechaValor" + ng-model="cheque.fechaEmision" ng-required="true"/>
- +
-
+
+
+
+ +
+
+ placeholder="Fecha" + ng-model="cheque.fechaPresentacion" + ng-required="true"/>