Commit d9d2a4b1b373b786ed5b6226e693ee57fe75b425
Exists in
master
Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | 2 | [ |
3 | - '$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', | |
4 | - function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { | |
3 | + '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | |
4 | + 'focaModalService', | |
5 | + function( | |
6 | + $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService | |
7 | + ) { | |
5 | 8 | $scope.botonera = [ |
6 | 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
7 | 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
... | ... | @@ -293,18 +296,33 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
293 | 296 | ariaLabelledBy: 'Busqueda de Flete', |
294 | 297 | templateUrl: 'modal-flete.html', |
295 | 298 | controller: 'focaModalFleteController', |
296 | - size: 'lg' | |
299 | + size: 'lg', | |
300 | + resolve: { | |
301 | + parametrosFlete: | |
302 | + function() { | |
303 | + return { | |
304 | + flete: $scope.notaPedido.flete, | |
305 | + bomba: $scope.notaPedido.bomba, | |
306 | + kilometros: $scope.notaPedido.kilometros | |
307 | + }; | |
308 | + } | |
309 | + } | |
297 | 310 | } |
298 | 311 | ); |
299 | 312 | modalInstance.result.then( |
300 | - function(flete) { | |
301 | - $scope.limpiarFlete(); | |
302 | - $scope.notaPedido.fleteNombre = flete.nombre; | |
303 | - $scope.notaPedido.fleteId = flete.id; | |
304 | - $scope.choferes = flete.chofer; | |
305 | - $scope.vehiculos = flete.vehiculo; | |
306 | - | |
307 | - addCabecera('Flete:', flete.nombre); | |
313 | + function(datos) { | |
314 | + $scope.notaPedido.flete = datos.flete; | |
315 | + $scope.notaPedido.bomba = datos.bomba; | |
316 | + $scope.notaPedido.kilometros = datos.kilometros; | |
317 | + | |
318 | + addCabecera('Flete:', datos.flete); | |
319 | + if(datos.flete === 'si') { | |
320 | + addCabecera('Bomba:', datos.bomba); | |
321 | + addCabecera('Kilometros:', datos.kilometros); | |
322 | + } else { | |
323 | + removeCabecera('Bomba:'); | |
324 | + removeCabecera('Kilometros:'); | |
325 | + } | |
308 | 326 | }, function() { |
309 | 327 | |
310 | 328 | } |
... | ... | @@ -403,22 +421,18 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
403 | 421 | }; |
404 | 422 | |
405 | 423 | function addCabecera(label, valor) { |
406 | - let existe = false; | |
407 | - | |
408 | - for (var i = $scope.cabecera.length - 1; i >= 0; i--) { | |
409 | - if ($scope.cabecera[i].label === label) { | |
410 | - $scope.cabecera[i].valor = valor; | |
411 | - existe = true; | |
412 | - break; | |
413 | - } | |
414 | - | |
424 | + var propiedad = $filter('filter')($scope.cabecera, {label: label}); | |
425 | + if(propiedad.length === 1) { | |
426 | + propiedad[0].valor = valor; | |
427 | + } else { | |
428 | + $scope.cabecera.push({label: label, valor: valor}); | |
415 | 429 | } |
416 | - | |
417 | - if (!existe) { | |
418 | - $scope.cabecera.push({ | |
419 | - label: label, | |
420 | - valor: valor | |
421 | - }); | |
430 | + } | |
431 | + | |
432 | + function removeCabecera(label) { | |
433 | + var propiedad = $filter('filter')($scope.cabecera, {label: label}); | |
434 | + if(propiedad.length === 1){ | |
435 | + $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | |
422 | 436 | } |
423 | 437 | } |
424 | 438 | } |
src/views/nota-pedido.html
... | ... | @@ -167,23 +167,25 @@ |
167 | 167 | </table> |
168 | 168 | </div> |
169 | 169 | </div> |
170 | - <div class="col-auto my-2"> | |
171 | - <button | |
172 | - ng-click="crearNotaPedido()" | |
173 | - type="submit" | |
174 | - title="Crear nota pedido" | |
175 | - class="btn btn-default"> | |
176 | - Guardar | |
177 | - </button> | |
178 | - <br/> | |
179 | - <br/> | |
180 | - <button | |
181 | - ng-click="salir()" | |
182 | - type="button" | |
183 | - title="Salir" | |
184 | - class="btn btn-default"> | |
185 | - Salir | |
186 | - </button> | |
170 | + <div class="col-auto my-2 col-lg-2 botonera-lateral"> | |
171 | + <div class="row align-items-end"> | |
172 | + <div class="col-12"> | |
173 | + <button | |
174 | + ng-click="crearNotaPedido()" | |
175 | + type="submit" | |
176 | + title="Crear nota pedido" | |
177 | + class="btn btn-default btn-block mb-2"> | |
178 | + Guardar | |
179 | + </button> | |
180 | + <button | |
181 | + ng-click="salir()" | |
182 | + type="button" | |
183 | + title="Salir" | |
184 | + class="btn btn-default btn-block"> | |
185 | + Salir | |
186 | + </button> | |
187 | + </div> | |
188 | + </div> | |
187 | 189 | </div> |
188 | 190 | </div> |
189 | 191 | </div> |