Commit c8aa909c22ba29908c6a173ea8f41446bf46b850
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
Master See merge request !8
Showing
3 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -12,14 +12,14 @@ angular.module('focaAbmChofer') |
12 | 12 | label: 'Transportista', |
13 | 13 | image: 'cliente.png' |
14 | 14 | }]; |
15 | - $scope.focused = 1; | |
16 | 15 | |
17 | 16 | //SETEO BOTONERA LATERAL |
18 | 17 | $timeout(function() { |
19 | - focaBotoneraLateralService.showSalir(true); | |
18 | + focaBotoneraLateralService.showSalir(false); | |
20 | 19 | focaBotoneraLateralService.showPausar(false); |
21 | 20 | focaBotoneraLateralService.showCancelar(false); |
22 | 21 | focaBotoneraLateralService.showGuardar(false); |
22 | + focaBotoneraLateralService.addCustomButton('Salir', salir); | |
23 | 23 | }); |
24 | 24 | |
25 | 25 | if(focaAbmChoferService.transportistaSeleccionado.COD) { |
... | ... | @@ -79,13 +79,20 @@ angular.module('focaAbmChofer') |
79 | 79 | $scope.choferes = res.data; |
80 | 80 | }); |
81 | 81 | } |
82 | + | |
83 | + function salir() { | |
84 | + focaAbmChoferService.transportistaSeleccionado = {}; | |
85 | + $location.path('/'); | |
86 | + } | |
82 | 87 | } |
83 | 88 | ]) |
84 | 89 | .controller('focaAbmChoferController', [ |
85 | 90 | '$scope', 'focaAbmChoferService', '$routeParams', |
86 | - '$location', 'focaBotoneraLateralService', '$timeout', | |
91 | + '$location', 'focaBotoneraLateralService', '$timeout', 'focaModalService', | |
87 | 92 | function($scope, focaAbmChoferService, $routeParams, |
88 | - $location, focaBotoneraLateralService, $timeout) { | |
93 | + $location, focaBotoneraLateralService, $timeout, focaModalService) { | |
94 | + | |
95 | + $scope.focused = 1; | |
89 | 96 | $scope.nuevo = $routeParams.id === '0'; |
90 | 97 | $scope.chofer = {}; |
91 | 98 | $scope.transportistas = []; |
... | ... | @@ -135,12 +142,40 @@ angular.module('focaAbmChofer') |
135 | 142 | $location.path('/chofer'); |
136 | 143 | }; |
137 | 144 | |
138 | - $scope.guardar = function() { | |
139 | - $scope.chofer.idTransportista = $routeParams.idTransportista; | |
140 | - delete $scope.chofer.transportista; | |
141 | - focaAbmChoferService.guardarChofer($scope.chofer).then(function() { | |
142 | - $location.path('/chofer'); | |
143 | - }); | |
145 | + $scope.guardar = function(key) { | |
146 | + key = (typeof key === 'undefined') ? 13 : key; | |
147 | + | |
148 | + if(key === 13) { | |
149 | + validaDni().then(function() { | |
150 | + $scope.chofer.idTransportista = $routeParams.idTransportista; | |
151 | + delete $scope.chofer.transportista; | |
152 | + focaAbmChoferService.guardarChofer($scope.chofer).then(function() { | |
153 | + $location.path('/chofer'); | |
154 | + }); | |
155 | + }, function() { | |
156 | + focaModalService.alert('Dni existente'); | |
157 | + }); | |
158 | + } | |
144 | 159 | }; |
160 | + | |
161 | + function validaDni() { | |
162 | + return new Promise(function(resolve, reject) { | |
163 | + focaAbmChoferService | |
164 | + .getChoferPorTransportista(parseInt($routeParams.idTransportista)) | |
165 | + .then(function(res) { | |
166 | + //Valida si existe dni | |
167 | + var existe = res.data.filter(function(chofer) { | |
168 | + return chofer.dni === $scope.chofer.dni && | |
169 | + chofer.id !== $scope.chofer.id; | |
170 | + }); | |
171 | + | |
172 | + if(existe.length) { | |
173 | + reject(existe); | |
174 | + }else { | |
175 | + resolve(); | |
176 | + } | |
177 | + }); | |
178 | + }); | |
179 | + } | |
145 | 180 | } |
146 | 181 | ]); |
src/views/foca-abm-choferes-item.html
... | ... | @@ -9,18 +9,6 @@ |
9 | 9 | <form name="formChofer" class="col-md-12"> |
10 | 10 | <input type="hidden" name="id" ng-model="chofer.id" /> |
11 | 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> | |
22 | - </div> | |
23 | - <div class="form-group row"> | |
24 | 12 | <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> |
25 | 13 | <div class="col-sm-4"> |
26 | 14 | <input |
... | ... | @@ -47,6 +35,7 @@ |
47 | 35 | ng-keypress="next($event.keyCode)" |
48 | 36 | foca-focus="focused == 2" |
49 | 37 | ng-focus="focused = 2" |
38 | + ng-disabled="!nuevo" | |
50 | 39 | /> |
51 | 40 | </div> |
52 | 41 | </div> |
... | ... | @@ -59,7 +48,7 @@ |
59 | 48 | teclado-virtual |
60 | 49 | ng-model="chofer.telefono" |
61 | 50 | ng-required="true" |
62 | - ng-keypress="next($event.keyCode)" | |
51 | + ng-keypress="guardar($event.keyCode)" | |
63 | 52 | foca-focus="focused == 3" |
64 | 53 | ng-focus="focused = 3" |
65 | 54 | /> |
src/views/foca-abm-choferes-listado.html
... | ... | @@ -15,7 +15,6 @@ |
15 | 15 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> |
16 | 16 | <thead> |
17 | 17 | <tr> |
18 | - <th>Código</th> | |
19 | 18 | <th>Nombre</th> |
20 | 19 | <th>DNI</th> |
21 | 20 | <th>Teléfono</th> |
... | ... | @@ -32,7 +31,6 @@ |
32 | 31 | </thead> |
33 | 32 | <tbody> |
34 | 33 | <tr ng-repeat="chofer in choferes | filter:filters"> |
35 | - <td ng-bind="chofer.id"></td> | |
36 | 34 | <td ng-bind="chofer.nombre"></td> |
37 | 35 | <td ng-bind="chofer.dni"></td> |
38 | 36 | <td ng-bind="chofer.telefono"></td> |