Commit 75c33a9ec8698f26fca4513fa14bf57d0d6b4c09
1 parent
be8202bcb5
Exists in
master
and in
1 other branch
titles, disable boton guardar si no es valido
Showing
2 changed files
with
24 additions
and
23 deletions
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaBusquedaCliente') |
| 2 | 2 | .controller('focaBusquedaClienteModalController', [ |
| 3 | 3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', |
| 4 | - '$uibModal', 'focaModalService', | |
| 4 | + '$uibModal', 'focaModalService', '$timeout', | |
| 5 | 5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, |
| 6 | - $uibModal, focaModalService) { | |
| 6 | + $uibModal, focaModalService, $timeout) { | |
| 7 | 7 | |
| 8 | 8 | $scope.filters = ''; |
| 9 | 9 | $scope.primerBusqueda = false; |
| ... | ... | @@ -14,6 +14,8 @@ angular.module('focaBusquedaCliente') |
| 14 | 14 | $scope.currentPageClientes = []; |
| 15 | 15 | $scope.selectedClientes = -1; |
| 16 | 16 | $scope.ingreso = false; |
| 17 | + $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); | |
| 18 | + | |
| 17 | 19 | |
| 18 | 20 | $scope.cliente = { |
| 19 | 21 | COD: 0, |
| ... | ... | @@ -138,9 +140,11 @@ angular.module('focaBusquedaCliente') |
| 138 | 140 | templateUrl: 'modal-provincias.html', |
| 139 | 141 | controller: 'focaModalProvinciaController', |
| 140 | 142 | size: 'md', |
| 141 | - resolve: {filters: function() { | |
| 142 | - return $scope.cliente.provincia; | |
| 143 | - }} | |
| 143 | + resolve: { | |
| 144 | + filters: function() { | |
| 145 | + return $scope.cliente.provincia.NOMBRE; | |
| 146 | + } | |
| 147 | + } | |
| 144 | 148 | } |
| 145 | 149 | ); |
| 146 | 150 | modalInstance.result.then(function(provincia) { |
| ... | ... | @@ -303,8 +307,6 @@ angular.module('focaBusquedaCliente') |
| 303 | 307 | |
| 304 | 308 | $scope.guardar = function() { |
| 305 | 309 | |
| 306 | - if(!validarForm()) return; | |
| 307 | - | |
| 308 | 310 | $scope.cliente.PCX = $scope.cliente.provincia.ID; |
| 309 | 311 | $scope.cliente.LOX = $scope.cliente.localidad.ID; |
| 310 | 312 | $scope.cliente.IVA = $scope.cliente.iva.ID; |
| ... | ... | @@ -391,14 +393,5 @@ angular.module('focaBusquedaCliente') |
| 391 | 393 | $scope.selectedClientes = 0; |
| 392 | 394 | } |
| 393 | 395 | } |
| 394 | - | |
| 395 | - function validarForm() { | |
| 396 | - var regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); | |
| 397 | - if(!regexCuit.test($scope.cliente.CUIT)) { | |
| 398 | - focaModalService.alert('Número de CUIT inválido') | |
| 399 | - return false; | |
| 400 | - } | |
| 401 | - return true; | |
| 402 | - } | |
| 403 | 396 | } |
| 404 | 397 | ]); |
src/views/foca-busqueda-cliente-modal.html
| 1 | 1 | <div class="modal-header py-1"> |
| 2 | 2 | <div class="row w-100"> |
| 3 | - <div class="col-lg-6"> | |
| 3 | + <div class="col-lg-4"> | |
| 4 | 4 | <h5 class="modal-title my-1" ng-hide="ingreso">Búsqueda de Cliente</h5> |
| 5 | 5 | <h5 class="modal-title my-1" ng-show="ingreso">Crear Cliente</h5> |
| 6 | 6 | </div> |
| 7 | 7 | <div ng-show="ingreso" class="col-lg-6"> |
| 8 | - <div class="custom-control custom-checkbox"> | |
| 8 | + <div class="custom-control custom-checkbox mt-2"> | |
| 9 | 9 | <input |
| 10 | 10 | type="checkbox" |
| 11 | 11 | class="custom-control-input" |
| ... | ... | @@ -14,11 +14,12 @@ |
| 14 | 14 | <label class="custom-control-label" for="checkProspecto">¿Es prospecto?</label> |
| 15 | 15 | </div> |
| 16 | 16 | </div> |
| 17 | - <div class="input-group col-lg-6 pr-0 my-2"> | |
| 17 | + <div class="input-group col-lg-6 offset-lg-2 pr-0 my-2"> | |
| 18 | 18 | <button |
| 19 | 19 | class="btn btn-outline-primary mr-2" |
| 20 | 20 | ng-click="ingreso = true" |
| 21 | - ng-show="!ingreso"> | |
| 21 | + ng-show="!ingreso" | |
| 22 | + title="Nuevo"> | |
| 22 | 23 | <i class="fa fa-plus" aria-hidden="true"></i> |
| 23 | 24 | </button> |
| 24 | 25 | <input |
| ... | ... | @@ -106,7 +107,6 @@ |
| 106 | 107 | type="text" |
| 107 | 108 | class="form-control form-control-sm" |
| 108 | 109 | ng-model="cliente.codigo" |
| 109 | - ng-required="true" | |
| 110 | 110 | readonly |
| 111 | 111 | /> |
| 112 | 112 | </div> |
| ... | ... | @@ -255,7 +255,8 @@ |
| 255 | 255 | class="custom-control-input" |
| 256 | 256 | id="checkDistribuidor" |
| 257 | 257 | ng-model="cliente.ES_MAY" |
| 258 | - checked> | |
| 258 | + checked | |
| 259 | + disabled="disabled"> | |
| 259 | 260 | <label class="custom-control-label" for="checkDistribuidor">¿Este cliente es distribuidor?</label> |
| 260 | 261 | </div> |
| 261 | 262 | </div> |
| ... | ... | @@ -320,6 +321,8 @@ |
| 320 | 321 | placeholder="Ingrese CUIT" |
| 321 | 322 | ng-model="cliente.CUIT" |
| 322 | 323 | ng-required="true" |
| 324 | + ng-pattern="regexCuit" | |
| 325 | + ng-maxlength="13" | |
| 323 | 326 | teclado-virtual> |
| 324 | 327 | </div> |
| 325 | 328 | </div> |
| ... | ... | @@ -404,5 +407,10 @@ |
| 404 | 407 | </ul> |
| 405 | 408 | </nav> |
| 406 | 409 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
| 407 | - <button class="btn btn-sm btn-primary" type="button" ng-show="ingreso" ng-click="guardar()">Guardar</button> | |
| 410 | + <button | |
| 411 | + class="btn btn-sm btn-primary" | |
| 412 | + type="button" | |
| 413 | + ng-show="ingreso" | |
| 414 | + ng-click="guardar()" | |
| 415 | + ng-disabled="!formCliente.$valid">Guardar</button> | |
| 408 | 416 | </div> |