Commit f8d2c78a5328e55f8420d424f2c283e9696f7bc2
1 parent
35e80fb797
Exists in
master
si tiene datos cargados, confirmar para salir
Showing
1 changed file
with
20 additions
and
2 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -38,9 +38,10 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | 40 | $timeout(function() { |
| 41 | - focaBotoneraLateralService.showSalir(true); | |
| 41 | + focaBotoneraLateralService.showSalir(false); | |
| 42 | 42 | focaBotoneraLateralService.showPausar(true); |
| 43 | 43 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); |
| 44 | + focaBotoneraLateralService.addCustomButton('Salir', salir); | |
| 44 | 45 | }); |
| 45 | 46 | |
| 46 | 47 | $scope.crearCobranza = function() { |
| ... | ... | @@ -563,7 +564,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 563 | 564 | }); |
| 564 | 565 | } |
| 565 | 566 | |
| 566 | - function obtenerNumeroComprobante() { | |
| 567 | + function obtenerNumeroComprobante() { | |
| 567 | 568 | focaCrearCobranzaService.getNumeroRecibo().then( |
| 568 | 569 | function(res) { |
| 569 | 570 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); |
| ... | ... | @@ -575,6 +576,23 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 575 | 576 | } |
| 576 | 577 | ); |
| 577 | 578 | } |
| 579 | + | |
| 580 | + function salir() { | |
| 581 | + var cobranza = { | |
| 582 | + moneda: $scope.cobranza.moneda, | |
| 583 | + cotizacion: $scope.cobranza.cotizacion | |
| 584 | + }; | |
| 585 | + if(JSON.stringify($scope.cobranza) !== JSON.stringify(cobranza)) { | |
| 586 | + focaModalService | |
| 587 | + .confirm('¿Esta seguro de que desea salir? ' + | |
| 588 | + 'Se perderán todos los datos cargados.') | |
| 589 | + .then(function(data) { | |
| 590 | + if(data) $location.path('/'); | |
| 591 | + }); | |
| 592 | + }else { | |
| 593 | + $location.path('/'); | |
| 594 | + } | |
| 595 | + } | |
| 578 | 596 | obtenerNumeroComprobante(); |
| 579 | 597 | setearMonedaPorDefecto(); |
| 580 | 598 | } |