Commit e7825aeda7d5c250f6b13d7f436efb8767ab996b

Authored by Jose Pinto
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master(efernandez)

See merge request !37
... ... @@ -47,10 +47,10 @@
47 47 "strict": false,
48 48  
49 49 // Prohibit use of explicitly undeclared variables.
50   - "undef": true,
  50 + "undef": false,
51 51  
52 52 // Warn when variables are defined but never used.
53   - "unused": true,
  53 + "unused": false,
54 54  
55 55 // Para que funcione en angular
56 56 "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"],
src/js/controller.js
... ... @@ -20,12 +20,6 @@ angular.module('focaAbmVehiculo')
20 20 focaBotoneraLateralService.showGuardar(false);
21 21 focaBotoneraLateralService.addCustomButton('Salir', salir);
22 22  
23   - if ($localStorage.vehiculo) {
24   - var vehiculo = JSON.parse($localStorage.vehiculo);
25   - if (!vehiculo.idVehiculo) vehiculo.idVehiculo = 0;
26   - $location.path('/vehiculo/' + vehiculo.idVehiculo + '/' + vehiculo.idTransportista);
27   - }
28   -
29 23 if (focaAbmVehiculoService.transportistaSeleccionado.COD) {
30 24 elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado);
31 25 }
... ... @@ -34,7 +28,7 @@ angular.module('focaAbmVehiculo')
34 28 };
35 29 $scope.solicitarConfirmacion = function(vehiculo) {
36 30 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
37   - vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
  31 + vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
38 32 function(data) {
39 33 if (data) {
40 34 focaAbmVehiculoService.deleteVehiculo(vehiculo.id);
... ... @@ -83,7 +77,7 @@ angular.module('focaAbmVehiculo')
83 77 });
84 78 buscar(transportista.COD);
85 79 }
86   -
  80 +
87 81 function buscar(idTransportista) {
88 82 focaAbmVehiculoService
89 83 .getVehiculosPorTransportista(idTransportista)
... ... @@ -99,9 +93,9 @@ angular.module('focaAbmVehiculo')
99 93 ])
100 94 .controller('focaAbmVehiculoController', [
101 95 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
102   - 'focaModalService', '$timeout', 'focaBotoneraLateralService', '$window', '$localStorage', '$filter',
  96 + 'focaModalService', '$timeout', 'focaBotoneraLateralService', '$localStorage', '$filter',
103 97 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
104   - focaModalService, $timeout, focaBotoneraLateralService, $window, $localStorage, $filter) {
  98 + focaModalService, $timeout, focaBotoneraLateralService, $localStorage, $filter) {
105 99 $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false;
106 100 $scope.now = new Date();
107 101 $scope.focused = 1;
... ... @@ -160,7 +154,7 @@ angular.module('focaAbmVehiculo')
160 154 };
161 155  
162 156 function cancelar() {
163   - if ($scope.formVehiculo.$pristine == false) {
  157 + if (!$scope.formVehiculo.$pristine) {
164 158 focaModalService.confirm(
165 159 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
166 160 ).then(function(data) {
... ... @@ -186,6 +180,12 @@ angular.module('focaAbmVehiculo')
186 180 key = (typeof key === 'undefined') ? 13 : key;
187 181  
188 182 if (key === 13) {
  183 +
  184 + if ($scope.formVehiculo.$pristine) {
  185 + $scope.cancelar();
  186 + return;
  187 + }
  188 +
189 189 if (!$scope.vehiculo.codigo) {
190 190 focaModalService.alert('Ingrese unidad');
191 191 return;
... ... @@ -258,7 +258,7 @@ angular.module('focaAbmVehiculo')
258 258  
259 259 $scope.solicitarConfirmacionCisterna = function(cisterna, idx) {
260 260 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' +
261   - cisterna.id + ' ' + cisterna.codigo + ' ?').then(
  261 + cisterna.id + ' ' + cisterna.codigo + ' ?').then(
262 262 function(data) {
263 263 if (data) {
264 264 focaAbmVehiculoService.deleteCisterna(idx);
... ... @@ -299,7 +299,7 @@ angular.module('focaAbmVehiculo')
299 299 total += parseInt(cisterna.capacidad);
300 300 }
301 301 });
302   - return $scope.vehiculo.capacidad == total;
  302 + return $scope.vehiculo.capacidad === total;
303 303 }
304 304  
305 305 function guardarCisternas() {
src/js/controllerCisterna.js
... ... @@ -29,8 +29,7 @@ angular.module('focaAbmVehiculo')
29 29 focaBotoneraLateralService.addCustomButton('Cancelar', $scope.cancelar);
30 30 });
31 31  
32   - if ($routeParams.idx != -1) {
33   -
  32 + if ($routeParams.idx !== -1) {
34 33 $scope.cisterna = [$routeParams.idx];
35 34 focaAbmVehiculoService
36 35 .getCisternas($routeParams.idVehiculo)
... ... @@ -56,9 +55,10 @@ angular.module('focaAbmVehiculo')
56 55 valor: res.data.capacidad
57 56 });
58 57 });
  58 +
59 59 $scope.cancelar = function() {
60 60  
61   - if ($scope.formCisterna.$pristine == false) {
  61 + if (!$scope.formCisterna.$pristine) {
62 62 focaModalService.confirm(
63 63 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
64 64 ).then(function(data) {
... ... @@ -68,7 +68,13 @@ angular.module('focaAbmVehiculo')
68 68 });
69 69 }
70 70 };
71   - $scope.guardar = function() {
  71 +
  72 + $scope.guardar = function() {
  73 +
  74 + if ($scope.formCisterna.$pristine) {
  75 + $scope.cancelar();
  76 + return;
  77 + }
72 78  
73 79 if (!$scope.cisterna.codigo) {
74 80 focaModalService.alert('Ingrese codigo de cisterna');
... ... @@ -88,7 +94,7 @@ angular.module('focaAbmVehiculo')
88 94  
89 95 focaAbmVehiculoService
90 96 .guardarCisterna($scope.cisterna, $routeParams.idx);
91   -
  97 +
92 98 $timeout(function() {
93 99 $location.path('/vehiculo/' + $routeParams.idVehiculo +
94 100 '/' + $scope.transportista);
... ... @@ -124,11 +130,11 @@ angular.module('focaAbmVehiculo')
124 130 cisternas.forEach(function(cisterna, idx) {
125 131 //SI EL CODIGO YA EXISTE
126 132 if (cisterna.codigo === $scope.cisterna.codigo &&
127   - idx != $routeParams.idx &&
  133 + idx !== $routeParams.idx &&
128 134 !cisterna.desactivado) {
129 135 reject('Código de cisterna existente');
130 136 }
131   - if (idx != $routeParams.idx &&
  137 + if (idx !== $routeParams.idx &&
132 138 !cisterna.desactivado) {
133 139 totalCargado += cisterna.capacidad;
134 140 }