فهرست منبع

HUE-2312 [search] Fixed empty label on Leaflet map

Enrico Berti 11 سال پیش
والد
کامیت
9e7c7f8798
3فایلهای تغییر یافته به همراه14 افزوده شده و 12 حذف شده
  1. 8 1
      apps/search/src/search/templates/search.mako
  2. 3 3
      apps/search/static/js/search.ko.js
  3. 3 8
      desktop/core/static/js/ko.charts.js

+ 8 - 1
apps/search/src/search/templates/search.mako

@@ -1299,7 +1299,14 @@ function leafletMapChartDataTransformer(data) {
 
   data.counts.forEach(function(record){
     if (record.leafletmap) {
-      _data.push({lat: record.leafletmap.latitude, lng: record.leafletmap.longitude, label: record.leafletmap.label});
+      var _obj = {
+        lat: record.leafletmap.latitude,
+        lng: record.leafletmap.longitude
+      }
+      if (record.leafletmap.label != null && record.leafletmap.label != ""){
+        _obj.label = record.leafletmap.label;
+      }
+      _data.push(_obj);
     }
   });
 

+ 3 - 3
apps/search/static/js/search.ko.js

@@ -316,15 +316,15 @@ var Collection = function (vm, collection) {
   });
 
   self.template.leafletmapOn = ko.computed(function() {
-    return self.template.leafletmap.latitudeField() && self.template.leafletmap.longitudeField();
+    return self.template.leafletmap.latitudeField() != null && self.template.leafletmap.longitudeField() != null;
   });
   self.template.leafletmap.latitudeField.subscribe(function (newValue) {
-    if (self.template.leafletmapOn()) {
+    if (self.template.leafletmap.longitudeField() != null && newValue != null) {
       vm.search();
     }
   });
   self.template.leafletmap.longitudeField.subscribe(function (newValue) {
-    if (self.template.leafletmapOn()) {
+    if (self.template.leafletmap.latitudeField() != null && newValue != null) {
       vm.search();
     }
   });

+ 3 - 8
desktop/core/static/js/ko.charts.js

@@ -159,16 +159,11 @@ ko.bindingHandlers.leafletMapChart = {
       $(element).height(300);
     }
 
-    if (_data.length == 0){
-      $(element).hide();
+    if (((_options.visible != null && _options.visible) || _options.visible == null || typeof _options == "undefined") && _data.length > 0) {
+      $(element).show();
     }
     else {
-      if ((_options.visible != null && _options.visible) || _options.visible == null) {
-        $(element).show();
-      }
-      else {
-        $(element).hide();
-      }
+      $(element).hide();
     }
 
     var _map = null;