Commit 147f24460946e782d905d85194d9012f20b7d24d

Authored by Jose Pinto
1 parent 5162b47e46
Exists in master

Agrego campo tipo documento

src/js/controller.js
... ... @@ -101,6 +101,10 @@ angular.module('focaAbmChofer')
101 101 if (key === 13) $scope.focused++;
102 102 };
103 103  
  104 + focaAbmChoferService.getTiposDocumento().then(function(res) {
  105 + $scope.tiposDocumento = res.data;
  106 + });
  107 +
104 108 //SETEO BOTONERA LATERAL
105 109 $timeout(function() {
106 110 focaBotoneraLateralService.showSalir(false);
... ... @@ -144,7 +148,6 @@ angular.module('focaAbmChofer')
144 148  
145 149 $scope.guardar = function(key) {
146 150 key = (typeof key === 'undefined') ? 13 : key;
147   -
148 151 if(key === 13) {
149 152 validaDni().then(function() {
150 153 $scope.chofer.idTransportista = $routeParams.idTransportista;
... ... @@ -161,16 +164,11 @@ angular.module('focaAbmChofer')
161 164 function validaDni() {
162 165 return new Promise(function(resolve, reject) {
163 166 focaAbmChoferService
164   - .getChoferPorTransportista(parseInt($routeParams.idTransportista))
  167 + .getChoferPorDni($scope.chofer.dni)
165 168 .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);
  169 + if(res.data.id &&
  170 + $scope.chofer.id !== res.data.id) {
  171 + reject(res.data);
174 172 }else {
175 173 resolve();
176 174 }
... ... @@ -10,6 +10,9 @@ angular.module('focaAbmChofer')
10 10 getChoferPorTransportista: function(id) {
11 11 return $http.get(API_ENDPOINT.URL + '/chofer/transportista/' + id);
12 12 },
  13 + getChoferPorDni: function(dni) {
  14 + return $http.post(API_ENDPOINT.URL + '/chofer/dni', {dni: dni});
  15 + },
13 16 guardarChofer: function(chofer) {
14 17 return $http.post(API_ENDPOINT.URL + '/chofer', {chofer: chofer});
15 18 },
... ... @@ -22,6 +25,9 @@ angular.module('focaAbmChofer')
22 25 deleteChofer: function(id) {
23 26 return $http.delete(API_ENDPOINT.URL + '/chofer/' + id);
24 27 },
  28 + getTiposDocumento: function() {
  29 + return $http.get(API_ENDPOINT.URL + '/tipo-documento');
  30 + },
25 31 transportistaSeleccionado: {}
26 32 };
27 33 }]);
src/views/foca-abm-choferes-item.html
... ... @@ -24,6 +24,16 @@
24 24 </div>
25 25 </div>
26 26 <div class="form-group row">
  27 + <label class="offset-sm-1 col-sm-2 col-form-label">Tipo documento</label>
  28 + <div class="col-sm-4">
  29 + <select
  30 + class="form-control"
  31 + ng-options="tipoDocumento.id as tipoDocumento.descripcion for tipoDocumento in tiposDocumento track by tipoDocumento.id"
  32 + ng-model="chofer.idTipoDocumento">
  33 + </select>
  34 + </div>
  35 + </div>
  36 + <div class="form-group row">
27 37 <label class="offset-sm-1 col-sm-2 col-form-label">DNI</label>
28 38 <div class="col-sm-4">
29 39 <input
src/views/foca-abm-choferes-listado.html
... ... @@ -16,7 +16,7 @@
16 16 <thead>
17 17 <tr>
18 18 <th>Nombre</th>
19   - <th>DNI</th>
  19 + <th>Documento</th>
20 20 <th>Teléfono</th>
21 21 <th class="text-center">
22 22 <button