diff --git a/src/js/controller.js b/src/js/controller.js index 6401cee..5aa783c 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -6,6 +6,7 @@ angular.module('focaAbmVehiculo') $uibModal, focaBotoneraLateralService, $timeout, $localStorage) { $scope.now = new Date(); + $scope.tipo = ''; $scope.botonera = [{ label: 'Transportista', image: 'cliente.png' @@ -101,6 +102,7 @@ angular.module('focaAbmVehiculo') $scope.nuevoCisterna = ($routeParams.idx > -1) ? false : true; $scope.now = new Date(); $scope.focused = 1; + $scope.tipo = ''; $scope.creando = false; $scope.crear = false; $scope.transportistaStamp = ''; @@ -115,6 +117,7 @@ angular.module('focaAbmVehiculo') }); if ($scope.nuevo) { + $scope.tipo = 'Crear Vehiculo'; focaAbmVehiculoService .getTransportistaPorId($routeParams.idTransportista) .then(function (res) { @@ -125,12 +128,17 @@ angular.module('focaAbmVehiculo') label: 'Transportista:', valor: codigo + ' - ' + res.data[0].ALI }); + $scope.$broadcast('addCabecera', { + label: 'Unidad:', + valor: 'NUEVO' + }); }); + } else { + $scope.tipo = 'Editar Vehiculo'; } $scope.vehiculo = {}; focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function (res) { - if (res.data) { var vehiculoSeteado = getLSVehiculo(); if (vehiculoSeteado === false) { @@ -257,23 +265,26 @@ angular.module('focaAbmVehiculo') return; } - validaCodigoUnidad().then(function () { - delete $scope.vehiculo.transportista; - delete $scope.vehiculo.cisternas; - focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) - .then(function (res) { - if ($scope.nuevo) { - $location.path('/vehiculo/' + res.data.id + - '/' + res.data.idTransportista); - } else { + if ($scope.nuevo) { + validaCodigoUnidad().then(function () { + delete $scope.vehiculo.transportista; + focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) + .then(function (res) { + $routeParams.idVehiculo = res.data.id; guardarCisternas($scope.cisternas).then(function () { - $location.path('/vehiculo'); + angular.element('#guardar').addClass('guardado'); + $timeout(function () {$location.path('/vehiculo');},300); }); - } - }); - }, function () { - focaModalService.alert('Código de unidad existente'); - }); + }); + }, function () { + focaModalService.alert('Código de unidad existente'); + }); + } else { + guardarCisternas($scope.cisternas).then(function () { + angular.element('#guardar').addClass('guardado'); + $timeout(function () {$location.path('/vehiculo');},500); + }); + } } }; //Agregar propiedades de cisterna @@ -349,6 +360,7 @@ angular.module('focaAbmVehiculo') return $scope.vehiculo.capacidad >= total; } function guardarCisternas() { + var cisternas = $scope.cisternas.map(function (cisterna) { return { id: cisterna.id, @@ -420,6 +432,6 @@ angular.module('focaAbmVehiculo') $scope.crear = false; }); }); - } + } } ]); diff --git a/src/views/foca-abm-vehiculos-item.html b/src/views/foca-abm-vehiculos-item.html index fd62da9..170a3d6 100644 --- a/src/views/foca-abm-vehiculos-item.html +++ b/src/views/foca-abm-vehiculos-item.html @@ -1,6 +1,6 @@
- + | - - | + +
-
-
-
-
-
+
+
+
+
- |
+
+
||||