Commit 91d0b72e38f0dbd4c84c3a46225d8f7c03f26010

Authored by Luigi
Exists in master

Merge branch 'master' into 'master'

Master

See merge request !4
src/js/controller.js
1 1 angular.module('focaAgendarVisita')
2 2 .controller('focaAgendarVisitaController', [
3   - '$scope', 'focaAgendarVisitaService', '$location', '$timeout',
  3 + '$scope', 'focaAgendarVisitaService', '$location','$localStorage', '$timeout',
4 4 '$uibModal', 'focaBotoneraLateralService', '$filter',
5 5 'focaModalService', 'focaSeguimientoService',
6   - function($scope, focaAgendarVisitaService, $location, $timeout,
  6 + function($scope, focaAgendarVisitaService, $location, $localStorage, $timeout,
7 7 $uibModal, focaBotoneraLateralService, $filter,
8 8 focaModalService, focaSeguimientoService
9 9 ) {
... ... @@ -18,6 +18,8 @@ angular.module('focaAgendarVisita')
18 18 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
19 19 });
20 20  
  21 + $timeout(function() {getLSVisita();});
  22 +
21 23 $scope.seleccionarCliente = function() {
22 24 var modalInstance = $uibModal.open(
23 25 {
... ... @@ -41,6 +43,22 @@ angular.module('focaAgendarVisita')
41 43 }
42 44 );
43 45 };
  46 + function setearVisita(visita){
  47 + $scope.visita = visita;
  48 + $scope.$broadcast('addCabecera', {
  49 + label: 'Cliente:',
  50 + valor: $filter('rellenarDigitos')(visita.cliente.cod, 3) + ' - ' +
  51 + visita.cliente.nom
  52 + });
  53 + }
  54 + function getLSVisita(){
  55 + var visita= JSON.parse($localStorage.visita || null);
  56 + if (visita) {
  57 + setearVisita(visita);
  58 + delete $localStorage.visita;
  59 + }
  60 + }
  61 +
44 62 $scope.seleccionarVisitante = function() {
45 63 var parametrosModal = {
46 64 query: '/vendedor-cobrador',
... ... @@ -106,6 +124,13 @@ angular.module('focaAgendarVisita')
106 124 if (key === 13) $scope.focused ++;
107 125 };
108 126  
  127 + $scope.$watch('visita', function(newValue, oldValue){
  128 + focaBotoneraLateralService.setPausarData({
  129 + label: 'visita',
  130 + val: newValue
  131 + });
  132 + });
  133 +
109 134 $scope.guardar = function() {
110 135 var rol;
111 136 if ($scope.visita.visitante.rol === 1) {
... ... @@ -18,7 +18,8 @@ angular.module('focaAgendarVisita')
18 18 label: 'Observaciones',
19 19 image: 'precios-condiciones.png'
20 20 }
21   - ]
22   - }
  21 + ];
  22 + }
23 23 };
24 24 }]);
  25 +
25 26 \ No newline at end of file