Commit 7fbb72e845f4d4ccfb43e9856646d3f9006e42df

Authored by Eric
1 parent dada99d278
Exists in master and in 1 other branch develop

pre commit

src/js/controller.js
... ... @@ -93,9 +93,9 @@ angular.module('focaAbmVehiculo')
93 93 ])
94 94 .controller('focaAbmVehiculoController', [
95 95 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
96   - 'focaModalService', '$timeout', 'focaBotoneraLateralService', '$window',
  96 + 'focaModalService', '$timeout', 'focaBotoneraLateralService',
97 97 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
98   - focaModalService, $timeout, focaBotoneraLateralService, $window) {
  98 + focaModalService, $timeout, focaBotoneraLateralService) {
99 99 $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false;
100 100 $scope.now = new Date();
101 101 $scope.focused = 1;
... ... @@ -162,8 +162,16 @@ angular.module('focaAbmVehiculo')
162 162 }
163 163 };
164 164 $scope.guardar = function(key) {
  165 +
165 166 key = (typeof key === 'undefined') ? 13 : key;
  167 +
166 168 if(key === 13) {
  169 +
  170 + if($scope.formVehiculo.$pristine) {
  171 + $scope.cancelar();
  172 + return;
  173 + }
  174 +
167 175 //Valida si existe numero de unidad
168 176 if(!validaTotalCargas() && !$scope.nuevo) {
169 177 focaModalService.alert('La suma de las capacidades de las cisternas' +
... ... @@ -233,7 +241,7 @@ angular.module('focaAbmVehiculo')
233 241 total += parseInt(cisterna.capacidad);
234 242 }
235 243 });
236   - return $scope.vehiculo.capacidad == total;
  244 + return $scope.vehiculo.capacidad === total;
237 245 }
238 246  
239 247 function guardarCisternas() {
src/js/controllerCisterna.js
1 1 angular.module('focaAbmVehiculo')
2 2 .controller('focaAbmVehiculoCisternaController', [
3 3 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
4   - 'focaModalService', 'focaBotoneraLateralService', '$timeout', '$window',
  4 + 'focaModalService', 'focaBotoneraLateralService', '$timeout',
5 5 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
6   - focaModalService, focaBotoneraLateralService, $timeout, $window) {
  6 + focaModalService, focaBotoneraLateralService, $timeout) {
7 7 $scope.nuevo = ($routeParams.idx > -1) ? false : true;
8 8 $scope.editar = false;
9 9 $scope.now = new Date();
... ... @@ -54,6 +54,12 @@ angular.module('focaAbmVehiculo')
54 54 $location.path('/vehiculo/' + $routeParams.idVehiculo);
55 55 };
56 56 $scope.guardar = function() {
  57 +
  58 + if($scope.formCisterna.$pristine) {
  59 + $scope.cancelar();
  60 + return;
  61 + }
  62 +
57 63 if(!$scope.cisterna.unidadMedida) {
58 64 focaModalService.alert('Ingrese unidad de medida');
59 65 return;
... ... @@ -101,11 +107,11 @@ angular.module('focaAbmVehiculo')
101 107 cisternas.forEach(function(cisterna, idx) {
102 108 //SI EL CODIGO YA EXISTE
103 109 if(cisterna.codigo === $scope.cisterna.codigo &&
104   - idx != $routeParams.idx &&
  110 + idx !== $routeParams.idx &&
105 111 !cisterna.desactivado) {
106 112 reject('Código de cisterna existente');
107 113 }
108   - if(idx != $routeParams.idx &&
  114 + if(idx !== $routeParams.idx &&
109 115 !cisterna.desactivado) {
110 116 totalCargado += cisterna.capacidad;
111 117 }