Commit c971e4b21bc51596f7ffce944d3348bb2e76befb

Authored by Marcelo Puebla
Exists in master and in 1 other branch develop

Merge branch 'develop' of git.focasoftware.com:npm/foca-modal-localizar

1 { 1 {
2 "name": "foca-modal-localizar", 2 "name": "foca-modal-localizar",
3 "version": "v0.1.2A", 3 "version": "v0.1.2A",
4 "description": "Modal para localizar domicilio", 4 "description": "Modal para localizar domicilio",
5 "scripts": { 5 "scripts": {
6 "test": "echo \"Error: no test specified\" && exit 1", 6 "test": "echo \"Error: no test specified\" && exit 1",
7 "gulp-pre-commit": "gulp pre-commit", 7 "gulp-pre-commit": "gulp pre-commit",
8 "compile": "gulp uglify", 8 "compile": "gulp uglify",
9 "postinstall": "npm run compile && gulp clean-post-install", 9 "postinstall": "npm run compile && gulp clean-post-install",
10 "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+http://git.focasoftware.com/npm/foca-directivas.git" 10 "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git"
11 }, 11 },
12 "pre-commit": [ 12 "pre-commit": [
13 "gulp-pre-commit" 13 "gulp-pre-commit"
14 ], 14 ],
15 "repository": { 15 "repository": {
16 "type": "git", 16 "type": "git",
17 "url": "http://git.focasoftware.com/npm/foca-modal-localizar.git" 17 "url": "http://git.focasoftware.com/npm/foca-modal-localizar.git"
18 }, 18 },
19 "author": "Foca Software", 19 "author": "Foca Software",
20 "license": "ISC", 20 "license": "ISC",
21 "peerDependencies": { 21 "peerDependencies": {
22 "angular": "^1.7.4", 22 "angular": "^1.7.4",
23 "bootstrap": "^4.1.3", 23 "bootstrap": "^4.1.3",
24 "font-awesome": "^4.7.0", 24 "font-awesome": "^4.7.0",
25 "ui-bootstrap4": "^3.0.4", 25 "ui-bootstrap4": "^3.0.4",
26 "gulp": "^3.9.1", 26 "gulp": "^3.9.1",
27 "gulp-angular-templatecache": "^2.2.1", 27 "gulp-angular-templatecache": "^2.2.1",
28 "gulp-concat": "^2.6.1", 28 "gulp-concat": "^2.6.1",
29 "gulp-connect": "^5.6.1", 29 "gulp-connect": "^5.6.1",
30 "gulp-htmlmin": "^5.0.1", 30 "gulp-htmlmin": "^5.0.1",
31 "gulp-rename": "^1.4.0", 31 "gulp-rename": "^1.4.0",
32 "gulp-replace": "^1.0.0", 32 "gulp-replace": "^1.0.0",
33 "gulp-uglify": "^3.0.1", 33 "gulp-uglify": "^3.0.1",
34 "jquery": "^3.3.1", 34 "jquery": "^3.3.1",
35 "pump": "^3.0.0", 35 "pump": "^3.0.0",
36 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" 36 "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git"
37 }, 37 },
38 "devDependencies": { 38 "devDependencies": {
39 "angular": "^1.7.5", 39 "angular": "^1.7.5",
40 "bootstrap": "^4.1.3", 40 "bootstrap": "^4.1.3",
41 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", 41 "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git",
42 "font-awesome": "^4.7.0", 42 "font-awesome": "^4.7.0",
43 "gulp": "^3.9.1", 43 "gulp": "^3.9.1",
44 "gulp-angular-templatecache": "^2.2.3", 44 "gulp-angular-templatecache": "^2.2.3",
45 "gulp-clean": "^0.4.0", 45 "gulp-clean": "^0.4.0",
46 "gulp-concat": "^2.6.1", 46 "gulp-concat": "^2.6.1",
47 "gulp-connect": "^5.6.1", 47 "gulp-connect": "^5.6.1",
48 "gulp-htmlmin": "^5.0.1", 48 "gulp-htmlmin": "^5.0.1",
49 "gulp-jshint": "^2.1.0", 49 "gulp-jshint": "^2.1.0",
50 "gulp-rename": "^1.4.0", 50 "gulp-rename": "^1.4.0",
51 "gulp-replace": "^1.0.0", 51 "gulp-replace": "^1.0.0",
52 "gulp-uglify": "^3.0.1", 52 "gulp-uglify": "^3.0.1",
53 "jasmine-core": "^3.3.0", 53 "jasmine-core": "^3.3.0",
54 "jquery": "^3.3.1", 54 "jquery": "^3.3.1",
55 "jshint": "^2.9.6", 55 "jshint": "^2.9.6",
56 "leaflet": "^1.3.4", 56 "leaflet": "^1.3.4",
57 "pre-commit": "^1.2.2", 57 "pre-commit": "^1.2.2",
58 "pump": "^3.0.0", 58 "pump": "^3.0.0",
59 "ui-bootstrap4": "^3.0.5" 59 "ui-bootstrap4": "^3.0.5"
60 } 60 }
61 } 61 }
62 62
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 );
src/js/osm-directive.js
1 angular.module('focaModalLocalizar').directive('osmDireccion', function() { 1 angular.module('focaModalLocalizar').directive('osmDireccion', function() {
2 return { 2 return {
3 restrict: 'E', 3 restrict: 'E',
4 link: function(scope, el, attrs) { 4 link: function(scope, el, attrs) {
5 var contenedor = document.createElement('div'); 5 var contenedor = document.createElement('div');
6 contenedor.className = 'w-100 h-50 mt-3';
7 el.append(contenedor); 6 el.append(contenedor);
8 scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom); 7 scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom);
9 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
10 }, 9 },
11 controller: ['$scope', '$timeout', function($scope, $timeout) { 10 controller: ['$scope', '$timeout', function($scope, $timeout) {
12 //resuelve bug mapa gris en modales 11 //resuelve bug mapa gris en modales
13 $timeout(function() { 12 $timeout(function() {
14 $scope.map.invalidateSize(); 13 $scope.map.invalidateSize();
15 }, 100); 14 }, 100);
16 15
17 $scope.markers = []; 16 $scope.markers = [];
18 $scope.$watchGroup(['latitud', 'longitud'], function() { 17 $scope.$watchGroup(['latitud', 'longitud'], function() {
19 for(var i in $scope.markers) { 18 for(var i in $scope.markers) {
20 $scope.map.removeLayer($scope.markers[i]); 19 $scope.map.removeLayer($scope.markers[i]);
21 } 20 }
22 $scope.markers.push( 21 $scope.markers.push(
23 L.marker([$scope.latitud, $scope.longitud], {draggable: true}) 22 L.marker([$scope.latitud, $scope.longitud], {draggable: true})
24 .addTo($scope.map) 23 .addTo($scope.map)
25 .on('dragend', function() { 24 .on('dragend', function() {
26 $scope.latitud = this.getLatLng().lat; 25 $scope.latitud = this.getLatLng().lat;
27 $scope.longitud = this.getLatLng().lng; 26 $scope.longitud = this.getLatLng().lng;
28 $scope.$apply(); 27 $scope.$apply();
29 }) 28 })
30 ); 29 );
31 }); 30 });
32 31
33 $scope.$on('moveMap', function(evt, data) { 32 $scope.$on('moveMap', function(evt, data) {
34 $scope.map.panTo(new L.LatLng(data.latitud, data.longitud)); 33 $scope.map.panTo(new L.LatLng(data.latitud, data.longitud));
35 }); 34 });
36 }], 35 }],
37 scope: { 36 scope: {
38 latitud: '=', 37 latitud: '=',
39 longitud: '=', 38 longitud: '=',
40 zoom: '=' 39 zoom: '='
41 } 40 }
42 }; 41 };
43 }); 42 });
44 43