Commit e5eba1550d37482d3429dd177910bb1f26894897

Authored by Eric Fernandez
1 parent d9f4843a80
Exists in master

no muestra icono de arrastrar en remitos ya cargados

Showing 1 changed file with 4 additions and 4 deletions   Show diff stats
src/js/osm-directive.js
1 angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { 1 angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', 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 = 'border border-light rounded'; 6 contenedor.className = 'border border-light rounded';
7 el.append(contenedor); 7 el.append(contenedor);
8 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); 8 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom);
9 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 9 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
10 }, 10 },
11 controller: ['$scope', '$filter', function($scope, $filter) { 11 controller: ['$scope', '$filter', function($scope, $filter) {
12 $scope.markers = []; 12 $scope.markers = [];
13 $scope.$watch('marcadores', function() { 13 $scope.$watch('marcadores', function() {
14 for(var i in $scope.markers) { 14 for(var i in $scope.markers) {
15 $scope.map.removeLayer($scope.markers[i]); 15 $scope.map.removeLayer($scope.markers[i]);
16 } 16 }
17 $scope.markers = []; 17 $scope.markers = [];
18 18
19 angular.forEach($scope.marcadores, function(marcador) { 19 angular.forEach($scope.marcadores, function(marcador) {
20 var observacion = 20 var observacion =
21 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + 21 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' +
22 ( 22 (
23 marcador.notaPedido.vendedor ? 23 marcador.notaPedido.vendedor ?
24 marcador.notaPedido.vendedor.NomVen : 24 marcador.notaPedido.vendedor.NomVen :
25 '' 25 ''
26 ) + '<br/>'; 26 ) + '<br/>';
27 observacion += 'Fecha: ' + 27 observacion += 'Fecha: ' +
28 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 28 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
29 marcador.fecha.slice(11,19) + '<br/>'; 29 marcador.fecha.slice(11,19) + '<br/>';
30 observacion += 'Remito Nº: ' + $filter('comprobante')([ 30 observacion += 'Remito Nº: ' + $filter('comprobante')([
31 marcador.notaPedido.remito.sucursal, 31 marcador.notaPedido.remito.sucursal,
32 marcador.notaPedido.remito.numeroRemito 32 marcador.notaPedido.remito.numeroRemito
33 ]) + '<br/>'; 33 ]) + '<br/>';
34 observacion += 'Cliente: ' + 34 observacion += 'Cliente: ' +
35 marcador.notaPedido.cliente.NOM + '<br/>'; 35 marcador.notaPedido.cliente.NOM + '<br/>';
36 36
37 // if($scope.parametros.individual) { 37 // if($scope.parametros.individual) {
38 observacion += 38 observacion +=
39 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); 39 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$');
40 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; 40 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion;
41 41
42 if(marcador.distancia) { 42 if(marcador.distancia) {
43 observacion += '<br/>Distancia a casa central: ' + 43 observacion += '<br/>Distancia a casa central: ' +
44 marcador.distancia + 'km'; 44 marcador.distancia + 'km';
45 } 45 }
46 observacion += '<br/>';
47 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
48 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
49 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)';
50 var icon; 46 var icon;
51 if(marcador.notaPedido.remito.idUsuarioProceso) { 47 if(marcador.notaPedido.remito.idUsuarioProceso) {
52 //Asignado ROJO 48 //Asignado ROJO
53 icon = new L.Icon({ 49 icon = new L.Icon({
54 iconUrl: 'img/marker-icon-2x-red.png', 50 iconUrl: 'img/marker-icon-2x-red.png',
55 shadowUrl: 'img/marker-shadow.png', 51 shadowUrl: 'img/marker-shadow.png',
56 iconSize: [25, 41], 52 iconSize: [25, 41],
57 iconAnchor: [12, 41], 53 iconAnchor: [12, 41],
58 popupAnchor: [1, -34], 54 popupAnchor: [1, -34],
59 shadowSize: [41, 41] 55 shadowSize: [41, 41]
60 }); 56 });
61 }else { 57 }else {
58 observacion += '<br/>';
59 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
60 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
61 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)';
62 //Sin asignar VERDE 62 //Sin asignar VERDE
63 icon = new L.Icon({ 63 icon = new L.Icon({
64 iconUrl: 'img/marker-icon-2x-green.png', 64 iconUrl: 'img/marker-icon-2x-green.png',
65 shadowUrl: 'img/marker-shadow.png', 65 shadowUrl: 'img/marker-shadow.png',
66 iconSize: [25, 41], 66 iconSize: [25, 41],
67 iconAnchor: [12, 41], 67 iconAnchor: [12, 41],
68 popupAnchor: [1, -34], 68 popupAnchor: [1, -34],
69 shadowSize: [41, 41] 69 shadowSize: [41, 41]
70 }); 70 });
71 } 71 }
72 $scope.markers.push( 72 $scope.markers.push(
73 L.marker( 73 L.marker(
74 [marcador.latitud, marcador.longitud], {icon: icon}) 74 [marcador.latitud, marcador.longitud], {icon: icon})
75 .addTo($scope.map) 75 .addTo($scope.map)
76 .bindPopup(observacion) 76 .bindPopup(observacion)
77 .bindTooltip('Haga click para seleccionar') 77 .bindTooltip('Haga click para seleccionar')
78 ); 78 );
79 //abre marcador del primer punto 79 //abre marcador del primer punto
80 //$scope.markers[0].openPopup(); 80 //$scope.markers[0].openPopup();
81 }); 81 });
82 }); 82 });
83 }], 83 }],
84 scope: { 84 scope: {
85 latitud: '=', 85 latitud: '=',
86 longitud: '=', 86 longitud: '=',
87 zoom: '=', 87 zoom: '=',
88 marcadores: '=', 88 marcadores: '=',
89 parametros: '=' 89 parametros: '='