diff --git a/src/js/controller.js b/src/js/controller.js index 6cf861a..21cc8a9 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -154,7 +154,7 @@ angular.module('focaAbmVehiculo') $location.path('/vehiculo'); }; $scope.editar = function(key) { - if(key) { + if (key) { $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + key); } else { @@ -162,8 +162,24 @@ angular.module('focaAbmVehiculo') } }; $scope.guardar = function(key) { + + if (!$scope.vehiculo.codigo) { + focaModalService.alert('Ingrese unidad'); + return; + } else if (!$scope.vehiculo.tractor) { + focaModalService.alert('Ingrese dominio tractor'); + return; + } else if (!$scope.vehiculo.semi) { + focaModalService.alert('Ingrese dominio semi'); + return; + } else if (!$scope.vehiculo.capacidad) { + focaModalService.alert('Ingrse capacidad total'); + return; + } + + key = (typeof key === 'undefined') ? 13 : key; - if(key === 13) { + if (key === 13) { //Valida si existe numero de unidad if(!validaTotalCargas() && !$scope.nuevo) { focaModalService.alert('La suma de las capacidades de las cisternas' + diff --git a/src/js/controllerCisterna.js b/src/js/controllerCisterna.js index 72e5163..3d4d86a 100644 --- a/src/js/controllerCisterna.js +++ b/src/js/controllerCisterna.js @@ -7,7 +7,11 @@ angular.module('focaAbmVehiculo') $scope.nuevo = ($routeParams.idx > -1) ? false : true; $scope.editar = false; $scope.now = new Date(); - $scope.cisterna = {}; + $scope.cisterna = { + codigo: '', + capacidad: '', + unidadMedida: {} + }; $scope.focused = $scope.nuevo ? 1 : 2; $scope.next = function(key) { @@ -24,7 +28,8 @@ angular.module('focaAbmVehiculo') focaBotoneraLateralService.showGuardar(true, $scope.guardar); }); - if($routeParams.idx !== -1) { + if($routeParams.idx != -1) { + console.log('asd'); $scope.cisterna = [$routeParams.idx]; focaAbmVehiculoService .getCisternas($routeParams.idVehiculo) @@ -53,11 +58,19 @@ angular.module('focaAbmVehiculo') $scope.cancelar = function() { $location.path('/vehiculo/' + $routeParams.idVehiculo); }; - $scope.guardar = function() { - if(!$scope.cisterna.unidadMedida) { + $scope.guardar = function() { + + if (!$scope.cisterna.codigo) { + focaModalService.alert('Ingrese codigo de cisterna'); + return; + } else if (!$scope.cisterna.capacidad) { + focaModalService.alert('Ingrese capacidad'); + return; + } else if (!$scope.cisterna.idUnidadMedida) { focaModalService.alert('Ingrese unidad de medida'); return; } + validaCodigo() .then(function() { $scope.cisterna.idVehiculo = parseInt($routeParams.idVehiculo);