Commit 336ca8d5e98e9b7a8dd352003bd12a1431d83236

Authored by Nicolás Guarnieri
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !7
src/js/controller.js
1 angular.module('focaAbmVehiculo') 1 angular.module('focaAbmVehiculo')
2 .controller('focaAbmVehiculosController', [ 2 .controller('focaAbmVehiculosController', [
3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal', 3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal',
4 function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) { 4 function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) {
5 $scope.buscar = function(idTransportista) { 5 $scope.buscar = function(idTransportista) {
6 focaAbmVehiculoService 6 focaAbmVehiculoService
7 .getVehiculosPorTransportista(idTransportista) 7 .getVehiculosPorTransportista(idTransportista)
8 .then(function(datos) { 8 .then(function(datos) {
9 $scope.vehiculos = datos.data; 9 $scope.vehiculos = datos.data;
10 }); 10 });
11 }; 11 };
12 $scope.editar = function(id) { 12 $scope.editar = function(id) {
13 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); 13 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
14 }; 14 };
15 $scope.solicitarConfirmacion = function(vehiculo) { 15 $scope.solicitarConfirmacion = function(vehiculo) {
16 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + 16 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
17 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( 17 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
18 function(data) { 18 function(data) {
19 if(data) { 19 if(data) {
20 focaAbmVehiculoService.deleteVehiculo(vehiculo.id); 20 focaAbmVehiculoService.deleteVehiculo(vehiculo.id);
21 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 21 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
22 } 22 }
23 } 23 }
24 ); 24 );
25 }; 25 };
26 $scope.seleccionarTransportista = function() { 26 $scope.seleccionarTransportista = function() {
27 var modalInstance = $uibModal.open( 27 var modalInstance = $uibModal.open(
28 { 28 {
29 ariaLabelledBy: 'Busqueda de Transportista', 29 ariaLabelledBy: 'Busqueda de Transportista',
30 templateUrl: 'modal-proveedor.html', 30 templateUrl: 'modal-proveedor.html',
31 controller: 'focaModalProveedorCtrl', 31 controller: 'focaModalProveedorCtrl',
32 size: 'lg', 32 size: 'lg',
33 resolve: { 33 resolve: {
34 transportista: function() { 34 transportista: function() {
35 return true; 35 return true;
36 } 36 }
37 } 37 }
38 } 38 }
39 ); 39 );
40 modalInstance.result.then( 40 modalInstance.result.then(
41 function(transprotista) { 41 function(transprotista) {
42 $scope.idTransportista = transprotista.COD; 42 $scope.idTransportista = transprotista.COD;
43 $scope.filtros = transprotista.NOM.trim(); 43 $scope.filtros = transprotista.NOM.trim();
44 $scope.buscar(transprotista.COD); 44 $scope.buscar(transprotista.COD);
45 }, function() { 45 }, function() {
46 46
47 } 47 }
48 ); 48 );
49 }; 49 };
50 } 50 }
51 ]) 51 ])
52 .controller('focaAbmVehiculoController', [ 52 .controller('focaAbmVehiculoController', [
53 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', 53 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
54 'focaModalService', 54 'focaModalService',
55 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, 55 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
56 focaModalService) { 56 focaModalService) {
57 $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false; 57 $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false;
58 if($scope.nuevo) { 58 if($scope.nuevo) {
59 focaAbmVehiculoService 59 focaAbmVehiculoService
60 .getTransportistaPorId($routeParams.idTransportista) 60 .getTransportistaPorId($routeParams.idTransportista)
61 .then(function(res) { 61 .then(function(res) {
62 $scope.vehiculo.idTransportista = res.data.COD; 62 $scope.vehiculo.idTransportista = res.data.COD;
63 $scope.vehiculo.transportista = res.data; 63 $scope.vehiculo.transportista = res.data;
64 }); 64 });
65 } 65 }
66 $scope.vehiculo = {}; 66 $scope.vehiculo = {};
67 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { 67 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
68 if(res.data) $scope.vehiculo = res.data; 68 if(res.data) $scope.vehiculo = res.data;
69 }); 69 });
70 focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) 70 focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo)
71 .then(function(res) { 71 .then(function(res) {
72 $scope.cisternas = res.data; 72 $scope.cisternas = res.data;
73 }); 73 });
74 $scope.cancelar = function() { 74 $scope.cancelar = function() {
75 $location.path('/vehiculo'); 75 $location.path('/vehiculo');
76 }; 76 };
77 $scope.editar = function(id) { 77 $scope.editar = function(id) {
78 $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); 78 $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id);
79 }; 79 };
80 $scope.guardar = function() { 80 $scope.guardar = function() {
81 if(!$scope.vehiculo.transportista) { 81 if(!$scope.vehiculo.transportista) {
82 focaModalService.alert('Elija Transportista'); 82 focaModalService.alert('Elija Transportista');
83 return; 83 return;
84 } 84 }
85 delete $scope.vehiculo.transportista; 85 delete $scope.vehiculo.transportista;
86 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { 86 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) {
87 console.log(res.data); 87 if($scope.nuevo) {
88 $location.path('/vehiculo/' + res.data.id + '/' + res.data.idTransportista); 88 $location.path('/vehiculo/' + res.data.id + '/' + res.data.idTransportista);
89 } else {
90 $location.path('/vehiculo');
91 }
89 }); 92 });
90 }; 93 };
91 $scope.solicitarConfirmacionCisterna = function(cisterna) { 94 $scope.solicitarConfirmacionCisterna = function(cisterna) {
92 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + 95 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' +
93 cisterna.id + ' ' + cisterna.codigo + ' ?').then( 96 cisterna.id + ' ' + cisterna.codigo + ' ?').then(
94 function(data) { 97 function(data) {
95 if(data) { 98 if(data) {
96 focaAbmVehiculoService.deleteCisterna(cisterna.id); 99 focaAbmVehiculoService.deleteCisterna(cisterna.id);
97 $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); 100 $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1);
98 } 101 }
99 } 102 }
100 ); 103 );
101 }; 104 };
102 $scope.seleccionarTransportista = function() { 105 $scope.seleccionarTransportista = function() {
103 var modalInstance = $uibModal.open( 106 var modalInstance = $uibModal.open(
104 { 107 {
105 ariaLabelledBy: 'Busqueda de Transportista', 108 ariaLabelledBy: 'Busqueda de Transportista',
106 templateUrl: 'modal-proveedor.html', 109 templateUrl: 'modal-proveedor.html',
107 controller: 'focaModalProveedorCtrl', 110 controller: 'focaModalProveedorCtrl',
108 size: 'lg', 111 size: 'lg',
109 resolve: { 112 resolve: {
110 transportista: function() { 113 transportista: function() {
111 return true; 114 return true;
112 } 115 }
113 } 116 }
114 } 117 }
115 ); 118 );
116 modalInstance.result.then( 119 modalInstance.result.then(
117 function(transprotista) { 120 function(transprotista) {
118 $scope.vehiculo.idTransportista = transprotista.COD; 121 $scope.vehiculo.idTransportista = transprotista.COD;
119 $scope.vehiculo.transportista = transprotista; 122 $scope.vehiculo.transportista = transprotista;
120 }, function() { 123 }, function() {
121 124
122 } 125 }
123 ); 126 );
124 }; 127 };
125 } 128 }
126 ]); 129 ]);
127 130
src/views/foca-abm-vehiculos-listado.html
1 <div class="col-12"> 1 <div class="col-12">
2 <h4>Vehiculos</h4> 2 <h4>Vehiculos</h4>
3 <div class="col-4 form-group input-group"> 3 <div class="col-4 form-group input-group">
4 <input 4 <input
5 class="form-control form-control-sm" 5 class="form-control form-control-sm"
6 ng-model="filtros" 6 ng-model="filtros"
7 placeholder="Transportista" 7 placeholder="Transportista"
8 /> 8 />
9 <div class="input-group-append"> 9 <div class="input-group-append">
10 <button 10 <button
11 class="btn btn-outline-secondary form-control-sm" 11 class="btn btn-outline-secondary form-control-sm"
12 ng-click="seleccionarTransportista()" 12 ng-click="seleccionarTransportista()"
13 ><i class="fa fa-search" aria-hidden="true"></i></button> 13 ><i class="fa fa-search" aria-hidden="true"></i></button>
14 </div> 14 </div>
15 </div> 15 </div>
16 <!-- <div class="col-6 form-group"> 16 <!-- <div class="col-6 form-group">
17 <input 17 <input
18 type="text" 18 type="text"
19 teclado-virtual 19 teclado-virtual
20 class="form-control form-control-sm" 20 class="form-control form-control-sm"
21 placeholder="Búsqueda" 21 placeholder="Búsqueda"
22 ng-model="filtros" 22 ng-model="filtros"
23 /> 23 />
24 </div> --> 24 </div> -->
25 <table class="table table-sm table-striped table-dark"> 25 <table class="table table-sm table-striped table-dark">
26 <thead> 26 <thead>
27 <tr> 27 <tr>
28 <th>Unidad</th> 28 <th>Unidad</th>
29 <th>Tractor</th> 29 <th>Dominio Tractor</th>
30 <th>Semi</th> 30 <th>Dominio Semi</th>
31 <th>Capacidad</th> 31 <th>Capacidad</th>
32 <th>Cisternado</th>
33 <th class="text-center"> 32 <th class="text-center">
34 <button 33 <button
35 ng-disabled="!idTransportista" 34 ng-disabled="!idTransportista"
36 class="btn btn-default boton-accion" 35 class="btn btn-default boton-accion"
37 ng-click="editar(0)" 36 ng-click="editar(0)"
38 ><i class="fa fa-plus"></i> 37 ><i class="fa fa-plus"></i>
39 </button> 38 </button>
40 </th> 39 </th>
41 </tr> 40 </tr>
42 </thead> 41 </thead>
43 <tbody> 42 <tbody>
44 <tr ng-repeat="vehiculo in vehiculos | filter:filtros"> 43 <tr ng-repeat="vehiculo in vehiculos | filter:filtros">
45 <td ng-bind="vehiculo.codigo"></td> 44 <td ng-bind="vehiculo.codigo"></td>
46 <td ng-bind="vehiculo.tractor"></td> 45 <td ng-bind="vehiculo.tractor"></td>
47 <td ng-bind="vehiculo.semi"></td> 46 <td ng-bind="vehiculo.semi"></td>
48 <td ng-bind="vehiculo.capacidad"></td> 47 <td ng-bind="vehiculo.capacidadTotalCisternas"></td>
49 <td ng-bind="vehiculo.cisternado"></td>
50 <td class="text-center"> 48 <td class="text-center">
51 <button 49 <button
52 class="btn btn-default boton-accion" 50 class="btn btn-default boton-accion"
53 ng-click="editar(vehiculo.id)" 51 ng-click="editar(vehiculo.id)"
54 > 52 >
55 <i class="fa fa-pencil"></i> 53 <i class="fa fa-pencil"></i>
56 </button> 54 </button>
57 <button 55 <button
58 class="btn btn-default boton-accion" 56 class="btn btn-default boton-accion"
59 ng-click="solicitarConfirmacion(vehiculo)" 57 ng-click="solicitarConfirmacion(vehiculo)"
60 > 58 >
61 <i class="fa fa-trash"></i> 59 <i class="fa fa-trash"></i>
62 </button> 60 </button>
63 </td> 61 </td>
64 </tr> 62 </tr>
65 </body> 63 </body>
66 </table> 64 </table>
67 <a href="#!/" title="Salir" 65 <a href="#!/" title="Salir"
68 class="btn btn-secondary btn-block float-right col-md-2" 66 class="btn btn-secondary btn-block float-right col-md-2"
69 > 67 >
70 Salir 68 Salir
71 </a> 69 </a>
72 </div> 70 </div>
73 71