Commit cb2a3a072709f3e5d886fe2f85b1be8429167bc2
Exists in
master
and in
2 other branches
Merge branch 'develop' into 'master'
Develop See merge request !6
Showing
1 changed file
 
Show diff stats
src/js/controller.js
| 1 | angular.module('focaModalLocalizar') | 1 | angular.module('focaModalLocalizar') | 
| 2 | .controller('focaModalLocalizarController', | 2 | .controller('focaModalLocalizarController', | 
| 3 | [ | 3 | [ | 
| 4 | '$scope', | 4 | '$scope', | 
| 5 | '$uibModalInstance', | 5 | '$uibModalInstance', | 
| 6 | 'focaModalLocalizarService', | 6 | 'focaModalLocalizarService', | 
| 7 | 'direccion', | ||
| 8 | 'focaModalService', | 7 | 'focaModalService', | 
| 8 | 'parametros', | ||
| 9 | function($scope, $uibModalInstance, | 9 | function($scope, $uibModalInstance, | 
| 10 | focaModalLocalizarService, direccion, focaModalService) { | 10 | focaModalLocalizarService, focaModalService, parametros) { | 
| 11 | 11 | ||
| 12 | $scope.latitud = -32.89214159952345; | 12 | $scope.latitud = parametros.latitud || -32.89214159952345; | 
| 13 | $scope.longitud = -68.84572999101856; | 13 | $scope.longitud = parametros.longitud || -68.84572999101856; | 
| 14 | $scope.localizar = !!direccion; | 14 | $scope.localizar = !! parametros.direccion; | 
| 15 | 15 | ||
| 16 | if(direccion) { | 16 | if (parametros.direccion) { | 
| 17 | focaModalLocalizarService | 17 | focaModalLocalizarService | 
| 18 | .getLatLng({ | 18 | .getLatLng({ | 
| 19 | street: direccion.numero + ' ' + direccion.calle, | 19 | street: parametros.direccion.numero + ' ' + parametros.direccion.calle, | 
| 20 | country: 'Argentina', | 20 | country: 'Argentina', | 
| 21 | city: direccion.provincia, | 21 | city: parametros.direccion.provincia, | 
| 22 | county: direccion.localidad, | 22 | county: parametros.direccion.localidad, | 
| 23 | format: 'json' | 23 | format: 'json' | 
| 24 | }) | 24 | }) | 
| 25 | .then(function(res) { | 25 | .then(function(res) { | 
| 26 | if(res.data.length) { | 26 | if (res.data.length) { | 
| 27 | $scope.latitud = res.data[0].lat; | 27 | $scope.latitud = res.data[0].lat; | 
| 28 | $scope.longitud = res.data[0].lon; | 28 | $scope.longitud = res.data[0].lon; | 
| 29 | $scope.$broadcast('moveMap', { | 29 | $scope.$broadcast('moveMap', { | 
| 30 | latitud: $scope.latitud, | 30 | latitud: $scope.latitud, | 
| 31 | longitud: $scope.longitud | 31 | longitud: $scope.longitud | 
| 32 | }); | 32 | }); | 
| 33 | }else { | 33 | } else { | 
| 34 | focaModalService.alert('No se pudo localizar el domicilio'); | 34 | focaModalService.alert('No se pudo localizar el domicilio'); | 
| 35 | } | 35 | } | 
| 36 | }); | 36 | }); | 
| 37 | } | 37 | } | 
| 38 | 38 | ||
| 39 | $scope.cancel = function() { | 39 | $scope.cancel = function() { | 
| 40 | $uibModalInstance.dismiss(); | 40 | $uibModalInstance.dismiss(); | 
| 41 | }; | 41 | }; | 
| 42 | 42 | ||
| 43 | $scope.aceptar = function() { | 43 | $scope.aceptar = function() { | 
| 44 | $uibModalInstance.close({ | 44 | $uibModalInstance.close({ | 
| 45 | latitud: $scope.latitud, | 45 | latitud: $scope.latitud, | 
| 46 | longitud: $scope.longitud | 46 | longitud: $scope.longitud | 
| 47 | }); | 47 | }); | 
| 48 | }; | 48 | }; | 
| 49 | } | 49 | } | 
| 50 | ] | 50 | ] | 
| 51 | ); | 51 | ); |