Commit 056ea72544a42d5c76bce80abab5aff56be6a535

Authored by Jose Pinto
1 parent e6e7aa334a
Exists in master and in 1 other branch develop

si tiene datos cargados, confirmar para salir

Showing 1 changed file with 24 additions and 1 deletions   Show diff stats
src/js/controller.js
... ... @@ -56,9 +56,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
56 56  
57 57 //SETEO BOTONERA LATERAL
58 58 $timeout(function() {
59   - focaBotoneraLateralService.showSalir(true);
  59 + focaBotoneraLateralService.showSalir(false);
60 60 focaBotoneraLateralService.showPausar(true);
61 61 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido);
  62 + focaBotoneraLateralService.addCustomButton('Salir', salir);
62 63 });
63 64  
64 65 crearNotaPedidoService.getPrecioCondicion().then(
... ... @@ -838,5 +839,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
838 839 });
839 840 return result;
840 841 }
  842 +
  843 + function salir() {
  844 + var notaPedido = {
  845 + id: 0,
  846 + vendedor: {},
  847 + cliente: {},
  848 + proveedor: {},
  849 + domicilio: {dom: ''},
  850 + moneda: $scope.notaPedido.moneda,
  851 + cotizacion: $scope.notaPedido.cotizacion
  852 + };
  853 + if(JSON.stringify($scope.notaPedido) !== JSON.stringify(notaPedido)) {
  854 + focaModalService
  855 + .confirm('¿Esta seguro de que desea salir? ' +
  856 + 'Se perderán todos los datos cargados.')
  857 + .then(function(data) {
  858 + if(data) $location.path('/');
  859 + });
  860 + }else {
  861 + $location.path('/');
  862 + }
  863 + }
841 864 }
842 865 ]);