Commit 608a057800deb086b117a066cf6c74a3085c6cee

Authored by Eric Fernandez
1 parent fd7984733c
Exists in master and in 1 other branch develop

refactor vehiculos

src/js/controller.js
... ... @@ -10,7 +10,7 @@ angular.module('focaAbmVehiculo')
10 10 });
11 11 };
12 12 $scope.editar = function(id) {
13   - $location.path('/vehiculo/' + id);
  13 + $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
14 14 };
15 15 $scope.solicitarConfirmacion = function(vehiculo) {
16 16 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
... ... @@ -39,8 +39,9 @@ angular.module('focaAbmVehiculo')
39 39 );
40 40 modalInstance.result.then(
41 41 function(transprotista) {
42   - $scope.buscar(transprotista.COD);
  42 + $scope.idTransportista = transprotista.COD;
43 43 $scope.filtros = transprotista.NOM.trim();
  44 + $scope.buscar(transprotista.COD);
44 45 }, function() {
45 46  
46 47 }
... ... @@ -54,6 +55,14 @@ angular.module('focaAbmVehiculo')
54 55 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
55 56 focaModalService) {
56 57 $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false;
  58 + if($scope.nuevo) {
  59 + focaAbmVehiculoService
  60 + .getTransportistaPorId($routeParams.idTransportista)
  61 + .then(function(res) {
  62 + console.log(res.data);
  63 + $scope.vehiculo.transportista = res.data;
  64 + })
  65 + }
57 66 $scope.vehiculo = {};
58 67 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
59 68 if(res.data) $scope.vehiculo = res.data;
... ... @@ -11,7 +11,7 @@ angular.module('focaAbmVehiculo')
11 11 .config([
12 12 '$routeProvider',
13 13 function($routeProvider) {
14   - $routeProvider.when('/vehiculo/:idVehiculo', {
  14 + $routeProvider.when('/vehiculo/:idVehiculo/:idTransportista', {
15 15 controller: 'focaAbmVehiculoController',
16 16 templateUrl: 'src/views/foca-abm-vehiculos-item.html'
17 17 });
... ... @@ -30,6 +30,9 @@ angular.module('focaAbmVehiculo')
30 30 },
31 31 getVehiculosPorTransportista: function(id) {
32 32 return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id);
  33 + },
  34 + getTransportistaPorId: function(id) {
  35 + return $http.get(API_ENDPOINT.URL + '/transportista/' + id);
33 36 }
34 37 };
35 38 }]);
src/views/foca-abm-vehiculos-item.html
... ... @@ -10,14 +10,14 @@
10 10 ng-model="vehiculo.transportista.NOM"
11 11 readonly
12 12 />
13   - <div class="input-group-append">
  13 + <!-- <div class="input-group-append">
14 14 <button
15 15 class="btn btn-outline-secondary form-control"
16 16 type="button"
17 17 ng-click="seleccionarTransportista()">
18 18 <i class="fa fa-search" aria-hidden="true"></i>
19 19 </button>
20   - </div>
  20 + </div> -->
21 21 </div>
22 22 </div>
23 23 <div class="form-group row">
... ... @@ -32,7 +32,7 @@
32 32 </div>
33 33 </div>
34 34 <div class="form-group row">
35   - <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label>
  35 + <label class="offset-sm-1 col-sm-2 col-form-label">Dominio tractor</label>
36 36 <div class="col-sm-4">
37 37 <input
38 38 class="form-control"
... ... @@ -44,7 +44,7 @@
44 44 </div>
45 45 </div>
46 46 <div class="form-group row">
47   - <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label>
  47 + <label class="offset-sm-1 col-sm-2 col-form-label">Dominio semi</label>
48 48 <div class="col-sm-4">
49 49 <input
50 50 class="form-control"
src/views/foca-abm-vehiculos-listado.html
... ... @@ -25,12 +25,17 @@
25 25 <table class="table table-sm table-striped table-dark">
26 26 <thead>
27 27 <tr>
28   - <th>Código</th>
  28 + <th>Código</th>
29 29 <th>Tractor</th>
  30 + <th>Semi</th>
30 31 <th>Capacidad</th>
  32 + <th>Cisternado</th>
31 33 <th class="text-center">
32   - <button class="btn btn-default boton-accion" ng-click="editar(0)">
33   - <i class="fa fa-plus"></i>
  34 + <button
  35 + ng-disabled="!idTransportista"
  36 + class="btn btn-default boton-accion"
  37 + ng-click="editar(0)"
  38 + ><i class="fa fa-plus"></i>
34 39 </button>
35 40 </th>
36 41 </tr>
... ... @@ -39,7 +44,9 @@
39 44 <tr ng-repeat="vehiculo in vehiculos | filter:filtros">
40 45 <td ng-bind="vehiculo.id"></td>
41 46 <td ng-bind="vehiculo.tractor"></td>
  47 + <td ng-bind="vehiculo.semi"></td>
42 48 <td ng-bind="vehiculo.capacidad"></td>
  49 + <td ng-bind="vehiculo.cisternado"></td>
43 50 <td class="text-center">
44 51 <button
45 52 class="btn btn-default boton-accion"
... ... @@ -57,4 +64,9 @@
57 64 </tr>
58 65 </body>
59 66 </table>
  67 + <a href="#!/" title="Salir"
  68 + class="btn btn-secondary btn-block float-right col-md-2"
  69 + >
  70 + Salir
  71 + </a>
60 72 </div>