Commit d31279610b0a925e0f59d73fecc7f7a1e40fd616
1 parent
7fbb72e845
Exists in
master
code review
Showing
2 changed files
with
19 additions
and
19 deletions
 
Show diff stats
.jshintrc
| 1 | { | 1 | { | 
| 2 | /* | 2 | /* | 
| 3 | * ENVIRONMENTS | 3 | * ENVIRONMENTS | 
| 4 | * ================= | 4 | * ================= | 
| 5 | */ | 5 | */ | 
| 6 | 6 | ||
| 7 | // Define globals exposed by modern browsers. | 7 | // Define globals exposed by modern browsers. | 
| 8 | "browser": true, | 8 | "browser": true, | 
| 9 | 9 | ||
| 10 | // Define globals exposed by jQuery. | 10 | // Define globals exposed by jQuery. | 
| 11 | "jquery": true, | 11 | "jquery": true, | 
| 12 | 12 | ||
| 13 | // Define globals exposed by Node.js. | 13 | // Define globals exposed by Node.js. | 
| 14 | "node": true, | 14 | "node": true, | 
| 15 | 15 | ||
| 16 | // Allow ES6. | 16 | // Allow ES6. | 
| 17 | "esversion": 6, | 17 | "esversion": 6, | 
| 18 | 18 | ||
| 19 | /* | 19 | /* | 
| 20 | * ENFORCING OPTIONS | 20 | * ENFORCING OPTIONS | 
| 21 | * ================= | 21 | * ================= | 
| 22 | */ | 22 | */ | 
| 23 | 23 | ||
| 24 | // Force all variable names to use either camelCase style or UPPER_CASE | 24 | // Force all variable names to use either camelCase style or UPPER_CASE | 
| 25 | // with underscores. | 25 | // with underscores. | 
| 26 | "camelcase": true, | 26 | "camelcase": true, | 
| 27 | 27 | ||
| 28 | // Prohibit use of == and != in favor of === and !==. | 28 | // Prohibit use of == and != in favor of === and !==. | 
| 29 | "eqeqeq": true, | 29 | "eqeqeq": true, | 
| 30 | 30 | ||
| 31 | // Enforce tab width of 2 spaces. | 31 | // Enforce tab width of 2 spaces. | 
| 32 | "indent": 4, | 32 | "indent": 4, | 
| 33 | 33 | ||
| 34 | // Prohibit use of a variable before it is defined. | 34 | // Prohibit use of a variable before it is defined. | 
| 35 | "latedef": false, | 35 | "latedef": false, | 
| 36 | 36 | ||
| 37 | // Enforce line length to 100 characters | 37 | // Enforce line length to 100 characters | 
| 38 | "maxlen": 100, | 38 | "maxlen": 100, | 
| 39 | 39 | ||
| 40 | // Require capitalized names for constructor functions. | 40 | // Require capitalized names for constructor functions. | 
| 41 | "newcap": true, | 41 | "newcap": true, | 
| 42 | 42 | ||
| 43 | // Enforce use of single quotation marks for strings. | 43 | // Enforce use of single quotation marks for strings. | 
| 44 | "quotmark": "single", | 44 | "quotmark": "single", | 
| 45 | 45 | ||
| 46 | // Enforce placing 'use strict' at the top function scope | 46 | // Enforce placing 'use strict' at the top function scope | 
| 47 | "strict": false, | 47 | "strict": false, | 
| 48 | 48 | ||
| 49 | // Prohibit use of explicitly undeclared variables. | 49 | // Prohibit use of explicitly undeclared variables. | 
| 50 | "undef": true, | 50 | "undef": false, | 
| 51 | 51 | ||
| 52 | // Warn when variables are defined but never used. | 52 | // Warn when variables are defined but never used. | 
| 53 | "unused": true, | 53 | "unused": false, | 
| 54 | 54 | ||
| 55 | // Para que funcione en angular | 55 | // Para que funcione en angular | 
| 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | 
| 57 | /* | 57 | /* | 
| 58 | * RELAXING OPTIONS | 58 | * RELAXING OPTIONS | 
| 59 | * ================= | 59 | * ================= | 
| 60 | */ | 60 | */ | 
| 61 | 61 | ||
| 62 | // Suppress warnings about == null comparisons. | 62 | // Suppress warnings about == null comparisons. | 
| 63 | "eqnull": true | 63 | "eqnull": true | 
| 64 | } | 64 | } | 
| 65 | 65 | 
src/js/controller.js
| 1 | angular.module('focaAbmVehiculo') | 1 | angular.module('focaAbmVehiculo') | 
| 2 | .controller('focaAbmVehiculosController', [ | 2 | .controller('focaAbmVehiculosController', [ | 
| 3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', | 3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', | 
| 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | 
| 5 | function($scope, focaAbmVehiculoService, $location, focaModalService, | 5 | function($scope, focaAbmVehiculoService, $location, focaModalService, | 
| 6 | $uibModal, focaBotoneraLateralService, $timeout) { | 6 | $uibModal, focaBotoneraLateralService, $timeout) { | 
| 7 | 7 | ||
| 8 | $scope.now = new Date(); | 8 | $scope.now = new Date(); | 
| 9 | $scope.botonera = [{ | 9 | $scope.botonera = [{ | 
| 10 | label: 'Transportista', | 10 | label: 'Transportista', | 
| 11 | image: 'cliente.png' | 11 | image: 'cliente.png' | 
| 12 | }]; | 12 | }]; | 
| 13 | 13 | ||
| 14 | focaAbmVehiculoService.cleanCisternas(); | 14 | focaAbmVehiculoService.cleanCisternas(); | 
| 15 | 15 | ||
| 16 | //SETEO BOTONERA LATERAL | 16 | //SETEO BOTONERA LATERAL | 
| 17 | focaBotoneraLateralService.showSalir(false); | 17 | focaBotoneraLateralService.showSalir(false); | 
| 18 | focaBotoneraLateralService.showPausar(false); | 18 | focaBotoneraLateralService.showPausar(false); | 
| 19 | focaBotoneraLateralService.showCancelar(false); | 19 | focaBotoneraLateralService.showCancelar(false); | 
| 20 | focaBotoneraLateralService.showGuardar(false); | 20 | focaBotoneraLateralService.showGuardar(false); | 
| 21 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 21 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 
| 22 | 22 | ||
| 23 | if(focaAbmVehiculoService.transportistaSeleccionado.COD) { | 23 | if (focaAbmVehiculoService.transportistaSeleccionado.COD) { | 
| 24 | elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado); | 24 | elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado); | 
| 25 | } | 25 | } | 
| 26 | $scope.editar = function(id) { | 26 | $scope.editar = function(id) { | 
| 27 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); | 27 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); | 
| 28 | }; | 28 | }; | 
| 29 | $scope.solicitarConfirmacion = function(vehiculo) { | 29 | $scope.solicitarConfirmacion = function(vehiculo) { | 
| 30 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 30 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 
| 31 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 31 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 
| 32 | function(data) { | 32 | function(data) { | 
| 33 | if(data) { | 33 | if (data) { | 
| 34 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); | 34 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); | 
| 35 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 35 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 
| 36 | } | 36 | } | 
| 37 | } | 37 | } | 
| 38 | ); | 38 | ); | 
| 39 | }; | 39 | }; | 
| 40 | $scope.seleccionarTransportista = function() { | 40 | $scope.seleccionarTransportista = function() { | 
| 41 | var parametrosModal = { | 41 | var parametrosModal = { | 
| 42 | titulo: 'Búsqueda de Transportista', | 42 | titulo: 'Búsqueda de Transportista', | 
| 43 | query: '/transportista', | 43 | query: '/transportista', | 
| 44 | columnas: [ | 44 | columnas: [ | 
| 45 | { | 45 | { | 
| 46 | nombre: 'Código', | 46 | nombre: 'Código', | 
| 47 | propiedad: 'COD' | 47 | propiedad: 'COD' | 
| 48 | }, | 48 | }, | 
| 49 | { | 49 | { | 
| 50 | nombre: 'Nombre', | 50 | nombre: 'Nombre', | 
| 51 | propiedad: 'NOM' | 51 | propiedad: 'NOM' | 
| 52 | }, | 52 | }, | 
| 53 | { | 53 | { | 
| 54 | nombre: 'CUIT', | 54 | nombre: 'CUIT', | 
| 55 | propiedad: 'CUIT' | 55 | propiedad: 'CUIT' | 
| 56 | } | 56 | } | 
| 57 | ] | 57 | ] | 
| 58 | }; | 58 | }; | 
| 59 | focaModalService.modal(parametrosModal).then( | 59 | focaModalService.modal(parametrosModal).then( | 
| 60 | function(transportista) { | 60 | function(transportista) { | 
| 61 | elegirTransportista(transportista); | 61 | elegirTransportista(transportista); | 
| 62 | focaAbmVehiculoService.transportistaSeleccionado = transportista; | 62 | focaAbmVehiculoService.transportistaSeleccionado = transportista; | 
| 63 | }, function() { | 63 | }, function() { | 
| 64 | 64 | ||
| 65 | } | 65 | } | 
| 66 | ); | 66 | ); | 
| 67 | }; | 67 | }; | 
| 68 | function elegirTransportista(transportista) { | 68 | function elegirTransportista(transportista) { | 
| 69 | var codigo = ('00000' + transportista.COD).slice(-5); | 69 | var codigo = ('00000' + transportista.COD).slice(-5); | 
| 70 | $scope.idTransportista = transportista.COD; | 70 | $scope.idTransportista = transportista.COD; | 
| 71 | $scope.filtros = transportista.NOM.trim(); | 71 | $scope.filtros = transportista.NOM.trim(); | 
| 72 | $timeout(function() { | 72 | $timeout(function() { | 
| 73 | $scope.$broadcast('addCabecera', { | 73 | $scope.$broadcast('addCabecera', { | 
| 74 | label: 'Transportista:', | 74 | label: 'Transportista:', | 
| 75 | valor: codigo + ' - ' + transportista.NOM | 75 | valor: codigo + ' - ' + transportista.NOM | 
| 76 | }); | 76 | }); | 
| 77 | }); | 77 | }); | 
| 78 | buscar(transportista.COD); | 78 | buscar(transportista.COD); | 
| 79 | } | 79 | } | 
| 80 | 80 | ||
| 81 | function buscar(idTransportista) { | 81 | function buscar(idTransportista) { | 
| 82 | focaAbmVehiculoService | 82 | focaAbmVehiculoService | 
| 83 | .getVehiculosPorTransportista(idTransportista) | 83 | .getVehiculosPorTransportista(idTransportista) | 
| 84 | .then(function(datos) { | 84 | .then(function(datos) { | 
| 85 | $scope.vehiculos = datos.data; | 85 | $scope.vehiculos = datos.data; | 
| 86 | }); | 86 | }); | 
| 87 | } | 87 | } | 
| 88 | function salir() { | 88 | function salir() { | 
| 89 | focaAbmVehiculoService.transportistaSeleccionado = {}; | 89 | focaAbmVehiculoService.transportistaSeleccionado = {}; | 
| 90 | $location.path('/'); | 90 | $location.path('/'); | 
| 91 | } | 91 | } | 
| 92 | } | 92 | } | 
| 93 | ]) | 93 | ]) | 
| 94 | .controller('focaAbmVehiculoController', [ | 94 | .controller('focaAbmVehiculoController', [ | 
| 95 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', | 95 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', | 
| 96 | 'focaModalService', '$timeout', 'focaBotoneraLateralService', | 96 | 'focaModalService', '$timeout', 'focaBotoneraLateralService', | 
| 97 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, | 97 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, | 
| 98 | focaModalService, $timeout, focaBotoneraLateralService) { | 98 | focaModalService, $timeout, focaBotoneraLateralService) { | 
| 99 | $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false; | 99 | $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false; | 
| 100 | $scope.now = new Date(); | 100 | $scope.now = new Date(); | 
| 101 | $scope.focused = 1; | 101 | $scope.focused = 1; | 
| 102 | $scope.transportistaStamp = ''; | 102 | $scope.transportistaStamp = ''; | 
| 103 | $scope.cisternas = []; | 103 | $scope.cisternas = []; | 
| 104 | 104 | ||
| 105 | $timeout(function() { | 105 | $timeout(function() { | 
| 106 | focaBotoneraLateralService.showSalir(false); | 106 | focaBotoneraLateralService.showSalir(false); | 
| 107 | focaBotoneraLateralService.showPausar(false); | 107 | focaBotoneraLateralService.showPausar(false); | 
| 108 | focaBotoneraLateralService.showCancelar(false); | 108 | focaBotoneraLateralService.showCancelar(false); | 
| 109 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 109 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 
| 110 | focaBotoneraLateralService.addCustomButton('Salir', $scope.cancelar); | 110 | focaBotoneraLateralService.addCustomButton('Salir', $scope.cancelar); | 
| 111 | }); | 111 | }); | 
| 112 | 112 | ||
| 113 | if($scope.nuevo) { | 113 | if ($scope.nuevo) { | 
| 114 | focaAbmVehiculoService | 114 | focaAbmVehiculoService | 
| 115 | .getTransportistaPorId($routeParams.idTransportista) | 115 | .getTransportistaPorId($routeParams.idTransportista) | 
| 116 | .then(function(res) { | 116 | .then(function(res) { | 
| 117 | var codigo = ('00000' + res.data.COD).slice(-5); | 117 | var codigo = ('00000' + res.data.COD).slice(-5); | 
| 118 | $scope.vehiculo.idTransportista = res.data.COD; | 118 | $scope.vehiculo.idTransportista = res.data.COD; | 
| 119 | $scope.vehiculo.transportista = res.data; | 119 | $scope.vehiculo.transportista = res.data; | 
| 120 | $scope.$broadcast('addCabecera', { | 120 | $scope.$broadcast('addCabecera', { | 
| 121 | label: 'Transportista:', | 121 | label: 'Transportista:', | 
| 122 | valor: codigo + ' - ' + res.data.NOM | 122 | valor: codigo + ' - ' + res.data.NOM | 
| 123 | }); | 123 | }); | 
| 124 | }); | 124 | }); | 
| 125 | } | 125 | } | 
| 126 | $scope.vehiculo = {}; | 126 | $scope.vehiculo = {}; | 
| 127 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { | 127 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { | 
| 128 | if(res.data) { | 128 | if (res.data) { | 
| 129 | $scope.transportistaStamp = ('00000' + res.data.transportista.COD).slice(-5); | 129 | $scope.transportistaStamp = ('00000' + res.data.transportista.COD).slice(-5); | 
| 130 | $scope.transportistaStamp += ' - ' + res.data.transportista.NOM; | 130 | $scope.transportistaStamp += ' - ' + res.data.transportista.NOM; | 
| 131 | 131 | ||
| 132 | $scope.vehiculo = res.data; | 132 | $scope.vehiculo = res.data; | 
| 133 | $scope.$broadcast('addCabecera', { | 133 | $scope.$broadcast('addCabecera', { | 
| 134 | label: 'Transportista:', | 134 | label: 'Transportista:', | 
| 135 | valor: $scope.transportistaStamp | 135 | valor: $scope.transportistaStamp | 
| 136 | }); | 136 | }); | 
| 137 | $scope.$broadcast('addCabecera', { | 137 | $scope.$broadcast('addCabecera', { | 
| 138 | label: 'Unidad:', | 138 | label: 'Unidad:', | 
| 139 | valor: res.data.codigo | 139 | valor: res.data.codigo | 
| 140 | }); | 140 | }); | 
| 141 | focaAbmVehiculoService | 141 | focaAbmVehiculoService | 
| 142 | .getCisternas($routeParams.idVehiculo) | 142 | .getCisternas($routeParams.idVehiculo) | 
| 143 | .then(function(res) { | 143 | .then(function(res) { | 
| 144 | $scope.cisternas = res; | 144 | $scope.cisternas = res; | 
| 145 | $scope.$apply(); | 145 | $scope.$apply(); | 
| 146 | }); | 146 | }); | 
| 147 | } | 147 | } | 
| 148 | }); | 148 | }); | 
| 149 | 149 | ||
| 150 | $scope.next = function(key) { | 150 | $scope.next = function(key) { | 
| 151 | if (key === 13) $scope.focused++; | 151 | if (key === 13) $scope.focused++; | 
| 152 | }; | 152 | }; | 
| 153 | $scope.cancelar = function() { | 153 | $scope.cancelar = function() { | 
| 154 | $location.path('/vehiculo'); | 154 | $location.path('/vehiculo'); | 
| 155 | }; | 155 | }; | 
| 156 | $scope.editar = function(key) { | 156 | $scope.editar = function(key) { | 
| 157 | if(key) { | 157 | if (key) { | 
| 158 | $location.path('/vehiculo/' + $routeParams.idVehiculo + | 158 | $location.path('/vehiculo/' + $routeParams.idVehiculo + | 
| 159 | '/cisterna/' + key); | 159 | '/cisterna/' + key); | 
| 160 | } else { | 160 | } else { | 
| 161 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/0/'); | 161 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/0/'); | 
| 162 | } | 162 | } | 
| 163 | }; | 163 | }; | 
| 164 | $scope.guardar = function(key) { | 164 | $scope.guardar = function(key) { | 
| 165 | 165 | ||
| 166 | key = (typeof key === 'undefined') ? 13 : key; | 166 | key = (typeof key === 'undefined') ? 13 : key; | 
| 167 | 167 | ||
| 168 | if(key === 13) { | 168 | if (key === 13) { | 
| 169 | 169 | ||
| 170 | if($scope.formVehiculo.$pristine) { | 170 | if ($scope.formVehiculo.$pristine) { | 
| 171 | $scope.cancelar(); | 171 | $scope.cancelar(); | 
| 172 | return; | 172 | return; | 
| 173 | } | 173 | } | 
| 174 | 174 | ||
| 175 | //Valida si existe numero de unidad | 175 | //Valida si existe numero de unidad | 
| 176 | if(!validaTotalCargas() && !$scope.nuevo) { | 176 | if (!validaTotalCargas() && !$scope.nuevo) { | 
| 177 | focaModalService.alert('La suma de las capacidades de las cisternas' + | 177 | focaModalService.alert('La suma de las capacidades de las cisternas' + | 
| 178 | ' debe ser igual a la capacidad total del vehículo'); | 178 | ' debe ser igual a la capacidad total del vehículo'); | 
| 179 | return; | 179 | return; | 
| 180 | } | 180 | } | 
| 181 | validaCodigoUnidad().then(function() { | 181 | validaCodigoUnidad().then(function() { | 
| 182 | delete $scope.vehiculo.transportista; | 182 | delete $scope.vehiculo.transportista; | 
| 183 | delete $scope.vehiculo.cisternas; | 183 | delete $scope.vehiculo.cisternas; | 
| 184 | focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) | 184 | focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) | 
| 185 | .then(function(res) { | 185 | .then(function(res) { | 
| 186 | if ($scope.nuevo) { | 186 | if ($scope.nuevo) { | 
| 187 | $location.path('/vehiculo/' + res.data.id + | 187 | $location.path('/vehiculo/' + res.data.id + | 
| 188 | '/' + res.data.idTransportista); | 188 | '/' + res.data.idTransportista); | 
| 189 | } else { | 189 | } else { | 
| 190 | guardarCisternas().then(function() { | 190 | guardarCisternas().then(function() { | 
| 191 | $location.path('/vehiculo'); | 191 | $location.path('/vehiculo'); | 
| 192 | }); | 192 | }); | 
| 193 | } | 193 | } | 
| 194 | }); | 194 | }); | 
| 195 | }, function() { | 195 | }, function() { | 
| 196 | focaModalService.alert('Código de unidad existente'); | 196 | focaModalService.alert('Código de unidad existente'); | 
| 197 | }); | 197 | }); | 
| 198 | } | 198 | } | 
| 199 | 199 | ||
| 200 | }; | 200 | }; | 
| 201 | $scope.solicitarConfirmacionCisterna = function(cisterna, idx) { | 201 | $scope.solicitarConfirmacionCisterna = function(cisterna, idx) { | 
| 202 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + | 202 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + | 
| 203 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( | 203 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( | 
| 204 | function(data) { | 204 | function(data) { | 
| 205 | if(data) { | 205 | if (data) { | 
| 206 | focaAbmVehiculoService.deleteCisterna(idx); | 206 | focaAbmVehiculoService.deleteCisterna(idx); | 
| 207 | focaAbmVehiculoService | 207 | focaAbmVehiculoService | 
| 208 | .getCisternas($routeParams.idVehiculo) | 208 | .getCisternas($routeParams.idVehiculo) | 
| 209 | .then(function(res) { | 209 | .then(function(res) { | 
| 210 | $scope.cisternas = res; | 210 | $scope.cisternas = res; | 
| 211 | }); | 211 | }); | 
| 212 | } | 212 | } | 
| 213 | } | 213 | } | 
| 214 | ); | 214 | ); | 
| 215 | }; | 215 | }; | 
| 216 | 216 | ||
| 217 | function validaCodigoUnidad() { | 217 | function validaCodigoUnidad() { | 
| 218 | return new Promise(function(resolve, reject) { | 218 | return new Promise(function(resolve, reject) { | 
| 219 | focaAbmVehiculoService | 219 | focaAbmVehiculoService | 
| 220 | .getVehiculosPorTransportista(parseInt($routeParams.idTransportista)) | 220 | .getVehiculosPorTransportista(parseInt($routeParams.idTransportista)) | 
| 221 | .then(function(res) { | 221 | .then(function(res) { | 
| 222 | //Valida si existe numero de unidad | 222 | //Valida si existe numero de unidad | 
| 223 | var existe = res.data.filter(function(vehiculo) { | 223 | var existe = res.data.filter(function(vehiculo) { | 
| 224 | return vehiculo.codigo === $scope.vehiculo.codigo && | 224 | return vehiculo.codigo === $scope.vehiculo.codigo && | 
| 225 | vehiculo.id !== $scope.vehiculo.id; | 225 | vehiculo.id !== $scope.vehiculo.id; | 
| 226 | }); | 226 | }); | 
| 227 | 227 | ||
| 228 | if(existe.length) { | 228 | if (existe.length) { | 
| 229 | reject(existe); | 229 | reject(existe); | 
| 230 | }else { | 230 | } else { | 
| 231 | resolve(); | 231 | resolve(); | 
| 232 | } | 232 | } | 
| 233 | }); | 233 | }); | 
| 234 | }); | 234 | }); | 
| 235 | } | 235 | } | 
| 236 | 236 | ||
| 237 | function validaTotalCargas() { | 237 | function validaTotalCargas() { | 
| 238 | var total = 0; | 238 | var total = 0; | 
| 239 | $scope.cisternas.forEach(function(cisterna) { | 239 | $scope.cisternas.forEach(function(cisterna) { | 
| 240 | if(!cisterna.desactivado) { | 240 | if (!cisterna.desactivado) { | 
| 241 | total += parseInt(cisterna.capacidad); | 241 | total += parseInt(cisterna.capacidad); | 
| 242 | } | 242 | } | 
| 243 | }); | 243 | }); | 
| 244 | return $scope.vehiculo.capacidad === total; | 244 | return $scope.vehiculo.capacidad === total; | 
| 245 | } | 245 | } | 
| 246 | 246 | ||
| 247 | function guardarCisternas() { | 247 | function guardarCisternas() { | 
| 248 | var cisternas = $scope.cisternas.map(function(cisterna) { | 248 | var cisternas = $scope.cisternas.map(function(cisterna) { | 
| 249 | return { | 249 | return { | 
| 250 | id: cisterna.id, | 250 | id: cisterna.id, | 
| 251 | capacidad: parseFloat(cisterna.capacidad), | 251 | capacidad: parseFloat(cisterna.capacidad), | 
| 252 | codigo: cisterna.codigo, | 252 | codigo: cisterna.codigo, | 
| 253 | idUnidadMedida: cisterna.idUnidadMedida, | 253 | idUnidadMedida: cisterna.idUnidadMedida, | 
| 254 | idVehiculo: $routeParams.idVehiculo, | 254 | idVehiculo: $routeParams.idVehiculo, | 
| 255 | desactivado: cisterna.desactivado | 255 | desactivado: cisterna.desactivado | 
| 256 | }; | 256 | }; | 
| 257 | }); | 257 | }); | 
| 258 | 258 | ||
| 259 | return focaAbmVehiculoService.guardarCisternas(cisternas); | 259 | return focaAbmVehiculoService.guardarCisternas(cisternas); | 
| 260 | } | 260 | } | 
| 261 | } | 261 | } | 
| 262 | ]); | 262 | ]); | 
| 263 | 263 |