From d31279610b0a925e0f59d73fecc7f7a1e40fd616 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 15 Mar 2019 15:34:38 -0300 Subject: [PATCH] code review --- .jshintrc | 4 ++-- src/js/controller.js | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.jshintrc b/.jshintrc index d8cbb07..7aad02f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -47,10 +47,10 @@ "strict": false, // Prohibit use of explicitly undeclared variables. - "undef": true, + "undef": false, // Warn when variables are defined but never used. - "unused": true, + "unused": false, // Para que funcione en angular "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], diff --git a/src/js/controller.js b/src/js/controller.js index 64f8286..d53e2a5 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -20,7 +20,7 @@ angular.module('focaAbmVehiculo') focaBotoneraLateralService.showGuardar(false); focaBotoneraLateralService.addCustomButton('Salir', salir); - if(focaAbmVehiculoService.transportistaSeleccionado.COD) { + if (focaAbmVehiculoService.transportistaSeleccionado.COD) { elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado); } $scope.editar = function(id) { @@ -28,9 +28,9 @@ angular.module('focaAbmVehiculo') }; $scope.solicitarConfirmacion = function(vehiculo) { focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + - vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( + vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( function(data) { - if(data) { + if (data) { focaAbmVehiculoService.deleteVehiculo(vehiculo.id); $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); } @@ -77,7 +77,7 @@ angular.module('focaAbmVehiculo') }); buscar(transportista.COD); } - + function buscar(idTransportista) { focaAbmVehiculoService .getVehiculosPorTransportista(idTransportista) @@ -95,7 +95,7 @@ angular.module('focaAbmVehiculo') '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', 'focaModalService', '$timeout', 'focaBotoneraLateralService', function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, - focaModalService, $timeout, focaBotoneraLateralService) { + focaModalService, $timeout, focaBotoneraLateralService) { $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false; $scope.now = new Date(); $scope.focused = 1; @@ -110,7 +110,7 @@ angular.module('focaAbmVehiculo') focaBotoneraLateralService.addCustomButton('Salir', $scope.cancelar); }); - if($scope.nuevo) { + if ($scope.nuevo) { focaAbmVehiculoService .getTransportistaPorId($routeParams.idTransportista) .then(function(res) { @@ -125,7 +125,7 @@ angular.module('focaAbmVehiculo') } $scope.vehiculo = {}; focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { - if(res.data) { + if (res.data) { $scope.transportistaStamp = ('00000' + res.data.transportista.COD).slice(-5); $scope.transportistaStamp += ' - ' + res.data.transportista.NOM; @@ -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 { @@ -163,17 +163,17 @@ angular.module('focaAbmVehiculo') }; $scope.guardar = function(key) { - key = (typeof key === 'undefined') ? 13 : key; + key = (typeof key === 'undefined') ? 13 : key; - if(key === 13) { + if (key === 13) { - if($scope.formVehiculo.$pristine) { + if ($scope.formVehiculo.$pristine) { $scope.cancelar(); return; } //Valida si existe numero de unidad - if(!validaTotalCargas() && !$scope.nuevo) { + if (!validaTotalCargas() && !$scope.nuevo) { focaModalService.alert('La suma de las capacidades de las cisternas' + ' debe ser igual a la capacidad total del vehículo'); return; @@ -200,9 +200,9 @@ angular.module('focaAbmVehiculo') }; $scope.solicitarConfirmacionCisterna = function(cisterna, idx) { focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + - cisterna.id + ' ' + cisterna.codigo + ' ?').then( + cisterna.id + ' ' + cisterna.codigo + ' ?').then( function(data) { - if(data) { + if (data) { focaAbmVehiculoService.deleteCisterna(idx); focaAbmVehiculoService .getCisternas($routeParams.idVehiculo) @@ -225,9 +225,9 @@ angular.module('focaAbmVehiculo') vehiculo.id !== $scope.vehiculo.id; }); - if(existe.length) { + if (existe.length) { reject(existe); - }else { + } else { resolve(); } }); @@ -237,7 +237,7 @@ angular.module('focaAbmVehiculo') function validaTotalCargas() { var total = 0; $scope.cisternas.forEach(function(cisterna) { - if(!cisterna.desactivado) { + if (!cisterna.desactivado) { total += parseInt(cisterna.capacidad); } }); -- 1.9.1