Commit 61cf6ef413e205841a6d4f7c3716a5280b2a42c1
1 parent
8d5a298bc6
Exists in
master
and in
2 other branches
Nuevo diseño
Showing
7 changed files
with
168 additions
and
83 deletions
Show diff stats
index.html
... | ... | @@ -14,6 +14,8 @@ |
14 | 14 | <script src="node_modules/angular-route/angular-route.min.js"></script> |
15 | 15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
16 | 16 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
17 | + <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | |
18 | + | |
17 | 19 | |
18 | 20 | <!-- BUILD --> |
19 | 21 | <script src="src/js/app.js"></script> |
package.json
... | ... | @@ -38,6 +38,7 @@ |
38 | 38 | "angular": "^1.7.5", |
39 | 39 | "angular-route": "^1.7.5", |
40 | 40 | "bootstrap": "^4.1.3", |
41 | + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | |
41 | 42 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
42 | 43 | "font-awesome": "^4.7.0", |
43 | 44 | "gulp": "^3.9.1", |
src/js/controller.js
1 | 1 | angular.module('focaAbmChofer') |
2 | 2 | .controller('focaAbmChoferesController', [ |
3 | - '$scope', 'focaAbmChoferService', '$location', | |
3 | + '$scope', 'focaAbmChoferService', '$location', '$uibModal', | |
4 | 4 | 'focaModalService', 'focaBotoneraLateralService', '$timeout', |
5 | - function($scope, focaAbmChoferService, $location, focaModalService, | |
5 | + function($scope, focaAbmChoferService, $location, $uibModal, focaModalService, | |
6 | 6 | focaBotoneraLateralService, $timeout) { |
7 | 7 | |
8 | + $scope.now = new Date(); | |
8 | 9 | $scope.filters = ''; |
9 | 10 | $scope.choferes = []; |
10 | - $scope.choferesFiltrados = []; | |
11 | - | |
12 | - focaAbmChoferService.getChoferes().then(function(datos) { | |
13 | - $scope.choferes = datos.data; | |
14 | - $scope.choferesFiltrados = $scope.choferes; | |
15 | - }); | |
11 | + $scope.botonera = ['Transportista']; | |
12 | + $scope.focused = 1; | |
16 | 13 | |
17 | 14 | //SETEO BOTONERA LATERAL |
18 | 15 | $timeout(function() { |
... | ... | @@ -22,8 +19,12 @@ angular.module('focaAbmChofer') |
22 | 19 | focaBotoneraLateralService.showGuardar(false); |
23 | 20 | }); |
24 | 21 | |
22 | + if(focaAbmChoferService.transportistaSeleccionado.COD) { | |
23 | + elegirTransportista(focaAbmChoferService.transportistaSeleccionado); | |
24 | + } | |
25 | + | |
25 | 26 | $scope.editar = function(id) { |
26 | - $location.path('/chofer/' + id); | |
27 | + $location.path('/chofer/' + id + '/' + $scope.idTransportista); | |
27 | 28 | }; |
28 | 29 | |
29 | 30 | $scope.solicitarConfirmacion = function(chofer) { |
... | ... | @@ -35,8 +36,46 @@ angular.module('focaAbmChofer') |
35 | 36 | } |
36 | 37 | }); |
37 | 38 | }; |
38 | - | |
39 | 39 | |
40 | + $scope.seleccionarTransportista = function() { | |
41 | + var modalInstance = $uibModal.open( | |
42 | + { | |
43 | + ariaLabelledBy: 'Busqueda de Transportista', | |
44 | + templateUrl: 'modal-proveedor.html', | |
45 | + controller: 'focaModalProveedorCtrl', | |
46 | + size: 'lg', | |
47 | + resolve: { | |
48 | + transportista: function() { | |
49 | + return true; | |
50 | + } | |
51 | + } | |
52 | + } | |
53 | + ); | |
54 | + modalInstance.result.then( | |
55 | + function(transportista) { | |
56 | + elegirTransportista(transportista); | |
57 | + focaAbmChoferService.transportistaSeleccionado = transportista; | |
58 | + }, function() {} | |
59 | + ); | |
60 | + }; | |
61 | + | |
62 | + function elegirTransportista(transportista) { | |
63 | + buscar(transportista.COD); | |
64 | + var codigo = ('00000' + transportista.COD).slice(-5); | |
65 | + $scope.idTransportista = transportista.COD; | |
66 | + $timeout(function() { | |
67 | + $scope.$broadcast('addCabecera', { | |
68 | + label: 'Transportista:', | |
69 | + valor: codigo + ' - ' + transportista.NOM | |
70 | + }); | |
71 | + }); | |
72 | + } | |
73 | + | |
74 | + function buscar(id) { | |
75 | + focaAbmChoferService.getChoferPorTransportista(id).then(function(res) { | |
76 | + $scope.choferes = res.data; | |
77 | + }); | |
78 | + } | |
40 | 79 | } |
41 | 80 | ]) |
42 | 81 | .controller('focaAbmChoferController', [ |
... | ... | @@ -44,9 +83,13 @@ angular.module('focaAbmChofer') |
44 | 83 | '$location', 'focaBotoneraLateralService', '$timeout', |
45 | 84 | function($scope, focaAbmChoferService, $routeParams, |
46 | 85 | $location, focaBotoneraLateralService, $timeout) { |
47 | - | |
86 | + $scope.nuevo = $routeParams.id === '0'; | |
48 | 87 | $scope.chofer = {}; |
49 | 88 | $scope.transportistas = []; |
89 | + $scope.now = new Date(); | |
90 | + $scope.next = function(key) { | |
91 | + if (key === 13) $scope.focused++; | |
92 | + }; | |
50 | 93 | |
51 | 94 | //SETEO BOTONERA LATERAL |
52 | 95 | $timeout(function() { |
... | ... | @@ -56,8 +99,29 @@ angular.module('focaAbmChofer') |
56 | 99 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
57 | 100 | }); |
58 | 101 | |
102 | + if($scope.nuevo) { | |
103 | + focaAbmChoferService | |
104 | + .getTransportistaPorId($routeParams.idTransportista) | |
105 | + .then(function(res) { | |
106 | + var codigo = ('00000' + res.data.COD).slice(-5); | |
107 | + $scope.chofer.idTransportista = res.data.COD; | |
108 | + $scope.chofer.transportista = res.data; | |
109 | + $scope.$broadcast('addCabecera', { | |
110 | + label: 'Transportista:', | |
111 | + valor: codigo + ' - ' + res.data.NOM | |
112 | + }); | |
113 | + }); | |
114 | + } | |
115 | + | |
59 | 116 | focaAbmChoferService.getChofer($routeParams.id).then(function(res) { |
60 | - if(res.data) $scope.chofer = res.data; | |
117 | + if(res.data) { | |
118 | + var codigo = ('00000' + res.data.transportista.COD).slice(-5); | |
119 | + $scope.chofer = res.data; | |
120 | + $scope.$broadcast('addCabecera', { | |
121 | + label: 'Transportista:', | |
122 | + valor: codigo + ' - ' + res.data.transportista.NOM | |
123 | + }); | |
124 | + } | |
61 | 125 | }); |
62 | 126 | |
63 | 127 | focaAbmChoferService.getTransportistas().then(function(res) { |
... | ... | @@ -69,12 +133,11 @@ angular.module('focaAbmChofer') |
69 | 133 | }; |
70 | 134 | |
71 | 135 | $scope.guardar = function() { |
72 | - $scope.chofer.idTransportista = $scope.chofer.transportista.COD; | |
136 | + $scope.chofer.idTransportista = $routeParams.idTransportista; | |
73 | 137 | delete $scope.chofer.transportista; |
74 | 138 | focaAbmChoferService.guardarChofer($scope.chofer).then(function() { |
75 | 139 | $location.path('/chofer'); |
76 | 140 | }); |
77 | 141 | }; |
78 | - | |
79 | 142 | } |
80 | 143 | ]); |
src/js/route.js
... | ... | @@ -11,7 +11,7 @@ angular.module('focaAbmChofer') |
11 | 11 | .config([ |
12 | 12 | '$routeProvider', |
13 | 13 | function($routeProvider) { |
14 | - $routeProvider.when('/chofer/:id', { | |
14 | + $routeProvider.when('/chofer/:id/:idTransportista', { | |
15 | 15 | controller: 'focaAbmChoferController', |
16 | 16 | templateUrl: 'src/views/foca-abm-choferes-item.html' |
17 | 17 | }); |
src/js/service.js
... | ... | @@ -7,14 +7,21 @@ angular.module('focaAbmChofer') |
7 | 7 | getChofer: function(id) { |
8 | 8 | return $http.get(API_ENDPOINT.URL + '/chofer/' + id); |
9 | 9 | }, |
10 | + getChoferPorTransportista: function(id) { | |
11 | + return $http.get(API_ENDPOINT.URL + '/chofer/transportista/' + id); | |
12 | + }, | |
10 | 13 | guardarChofer: function(chofer) { |
11 | 14 | return $http.post(API_ENDPOINT.URL + '/chofer', {chofer: chofer}); |
12 | 15 | }, |
13 | 16 | getTransportistas: function() { |
14 | 17 | return $http.get(API_ENDPOINT.URL + '/transportista'); |
15 | 18 | }, |
19 | + getTransportistaPorId: function(id) { | |
20 | + return $http.get(API_ENDPOINT.URL + '/transportista/' + id); | |
21 | + }, | |
16 | 22 | deleteChofer: function(id) { |
17 | 23 | return $http.delete(API_ENDPOINT.URL + '/chofer/' + id); |
18 | - } | |
24 | + }, | |
25 | + transportistaSeleccionado: {} | |
19 | 26 | }; |
20 | 27 | }]); |
src/views/foca-abm-choferes-item.html
1 | -<h4 class="pt-4">Chofer</h4> | |
2 | -<form name="formChofer"> | |
3 | - <input type="hidden" name="id" ng-model="chofer.id" /> | |
4 | - <div class="form-group row"> | |
5 | - <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> | |
6 | - <div class="col-sm-4"> | |
7 | - <select class="form-control" ng-model="chofer.transportista" | |
8 | - ng-options="transportista as transportista.NOM for transportista in transportistas" | |
9 | - > | |
10 | - </select> | |
11 | - </div> | |
12 | - </div> | |
13 | - <div class="form-group row"> | |
14 | - <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> | |
15 | - <div class="col-sm-4"> | |
16 | - <input | |
17 | - class="form-control" | |
18 | - type="text" | |
19 | - teclado-virtual | |
20 | - ng-model="chofer.nombre" | |
21 | - ng-required="true" | |
22 | - /> | |
1 | +<div class="row"> | |
2 | + <foca-cabecera-facturador | |
3 | + titulo="'Chofer'" | |
4 | + fecha="now" | |
5 | + class="mb-0 col-lg-12" | |
6 | + ></foca-cabecera-facturador> | |
7 | +</div> | |
8 | +<div class="row"> | |
9 | + <form name="formChofer" class="col-md-12"> | |
10 | + <input type="hidden" name="id" ng-model="chofer.id" /> | |
11 | + <div class="form-group row"> | |
12 | + <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> | |
13 | + <div class="col-sm-4"> | |
14 | + <input | |
15 | + class="form-control" | |
16 | + type="text" | |
17 | + teclado-virtual | |
18 | + ng-model="chofer.transportista.NOM" | |
19 | + readonly | |
20 | + /> | |
21 | + </div> | |
23 | 22 | </div> |
24 | - </div> | |
25 | - <div class="form-group row"> | |
26 | - <label class="offset-sm-1 col-sm-2 col-form-label">DNI</label> | |
23 | + <div class="form-group row"> | |
24 | + <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> | |
27 | 25 | <div class="col-sm-4"> |
28 | 26 | <input |
29 | 27 | class="form-control" |
30 | 28 | type="text" |
31 | 29 | teclado-virtual |
32 | - ng-model="chofer.dni" | |
30 | + ng-model="chofer.nombre" | |
33 | 31 | ng-required="true" |
32 | + ng-keypress="next($event.keyCode)" | |
33 | + foca-focus="focused == 1" | |
34 | + ng-focus="focused = 1" | |
34 | 35 | /> |
35 | 36 | </div> |
36 | 37 | </div> |
37 | - <div class="form-group row"> | |
38 | - <label class="offset-sm-1 col-sm-2 col-form-label">Teléfono</label> | |
39 | - <div class="col-sm-4"> | |
40 | - <input | |
41 | - class="form-control" | |
42 | - type="text" | |
43 | - teclado-virtual | |
44 | - ng-model="chofer.telefono" | |
45 | - ng-required="true" | |
46 | - /> | |
38 | + <div class="form-group row"> | |
39 | + <label class="offset-sm-1 col-sm-2 col-form-label">DNI</label> | |
40 | + <div class="col-sm-4"> | |
41 | + <input | |
42 | + class="form-control" | |
43 | + type="number" | |
44 | + teclado-virtual | |
45 | + ng-model="chofer.dni" | |
46 | + ng-required="true" | |
47 | + ng-keypress="next($event.keyCode)" | |
48 | + foca-focus="focused == 2" | |
49 | + ng-focus="focused = 2" | |
50 | + /> | |
51 | + </div> | |
52 | + </div> | |
53 | + <div class="form-group row"> | |
54 | + <label class="offset-sm-1 col-sm-2 col-form-label">Teléfono</label> | |
55 | + <div class="col-sm-4"> | |
56 | + <input | |
57 | + class="form-control" | |
58 | + type="text" | |
59 | + teclado-virtual | |
60 | + ng-model="chofer.telefono" | |
61 | + ng-required="true" | |
62 | + ng-keypress="next($event.keyCode)" | |
63 | + foca-focus="focused == 3" | |
64 | + ng-focus="focused = 3" | |
65 | + /> | |
66 | + </div> | |
47 | 67 | </div> |
48 | - </div> | |
49 | -</form> | |
68 | + </form> | |
69 | +</div> |
src/views/foca-abm-choferes-listado.html
1 | 1 | <div class="row"> |
2 | - <div class="col-12 col-md-10 pt-4 pr-4 pl-4"> | |
3 | - <h4 class="mb-4">Choferes</h4> | |
4 | - <div class="form-group input-group"> | |
5 | - <input | |
6 | - type="text" | |
7 | - class="form-control form-control-sm" | |
8 | - id="search" | |
9 | - placeholder="Búsqueda" | |
10 | - ng-model="filters" | |
11 | - teclado-virtual | |
12 | - ng-keypress="busquedaPress($event.keyCode)" | |
13 | - /> | |
14 | - <div class="input-group-append"> | |
15 | - <button | |
16 | - ladda="searchLoading" | |
17 | - class="btn btn-outline-secondary" | |
18 | - type="button" | |
19 | - ng-click="busquedaPress(13)" | |
20 | - > | |
21 | - <i class="fa fa-search" aria-hidden="true"></i> | |
22 | - </button> | |
2 | + <foca-cabecera-facturador | |
3 | + titulo="'Choferes'" | |
4 | + fecha="now" | |
5 | + class="mb-0 col-lg-12" | |
6 | + ></foca-cabecera-facturador> | |
7 | +</div> | |
8 | +<div class="row"> | |
9 | + <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | |
10 | + <div class="row px-5 py-2 botonera-secundaria"> | |
11 | + <div class="col-12"> | |
12 | + <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> | |
23 | 13 | </div> |
24 | 14 | </div> |
25 | - <table class="table table-sm table-striped table-dark mb-0"> | |
15 | + <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | |
26 | 16 | <thead> |
27 | 17 | <tr> |
28 | 18 | <th>Código</th> |
29 | 19 | <th>Nombre</th> |
30 | 20 | <th>DNI</th> |
31 | 21 | <th>Teléfono</th> |
32 | - <th>Transportista</th> | |
33 | 22 | <th class="text-center"> |
34 | - <button class="btn btn-default boton-accion" ng-click="editar(0)"> | |
23 | + <button | |
24 | + ng-disabled="!idTransportista" | |
25 | + title="Agregar" | |
26 | + class="btn btn-outline-debo boton-accion" | |
27 | + ng-click="editar(0)"> | |
35 | 28 | <i class="fa fa-plus"></i> |
36 | 29 | </button> |
37 | 30 | </th> |
... | ... | @@ -43,16 +36,17 @@ |
43 | 36 | <td ng-bind="chofer.nombre"></td> |
44 | 37 | <td ng-bind="chofer.dni"></td> |
45 | 38 | <td ng-bind="chofer.telefono"></td> |
46 | - <td ng-bind="chofer.transportista.NOM || 'No tiene'"></td> | |
47 | 39 | <td class="text-center"> |
48 | 40 | <button |
49 | - class="btn btn-default boton-accion" | |
41 | + class="btn btn-outline-dark boton-accion" | |
42 | + title="Editar" | |
50 | 43 | ng-click="editar(chofer.id)" |
51 | 44 | > |
52 | 45 | <i class="fa fa-pencil"></i> |
53 | 46 | </button> |
54 | 47 | <button |
55 | - class="btn btn-default boton-accion" | |
48 | + class="btn btn-outline-dark boton-accion" | |
49 | + title="Eliminar" | |
56 | 50 | ng-click="solicitarConfirmacion(chofer)" |
57 | 51 | > |
58 | 52 | <i class="fa fa-trash"></i> |
... | ... | @@ -61,7 +55,5 @@ |
61 | 55 | </tr> |
62 | 56 | </body> |
63 | 57 | </table> |
64 | - | |
65 | 58 | </div> |
66 | - | |
67 | 59 | </div> |