Browse Source

[core] Fixes Leaflet 'no data available' problem

Enrico Berti 10 years ago
parent
commit
46c181d37c

+ 2 - 2
apps/search/src/search/templates/search.mako

@@ -1242,13 +1242,13 @@ ${ dashboard.layout_skeleton() }
       <select data-bind="options: $root.collection.template.fieldsNames, value: $root.collection.template.leafletmap.labelField, optionsCaption: '${ _('Choose...') }'"></select>
       <select data-bind="options: $root.collection.template.fieldsNames, value: $root.collection.template.leafletmap.labelField, optionsCaption: '${ _('Choose...') }'"></select>
     </div>
     </div>
 
 
-    <div data-bind="leafletMapChart: {visible: $root.hasRetrievedResults() && $root.collection.template.leafletmapOn(), datum: {counts: $root.response()},
+    <div data-bind="leafletMapChart: {visible: $root.hasRetrievedResults() && $root.collection.template.leafletmapOn(), isLoading: isLoading(), datum: {counts: $root.response()},
       transformer: leafletMapChartDataTransformer,
       transformer: leafletMapChartDataTransformer,
       onComplete: function(){ var widget = viewModel.getWidgetById(id()); if (widget != null) { widget.isLoading(false)}; } }">
       onComplete: function(){ var widget = viewModel.getWidgetById(id()); if (widget != null) { widget.isLoading(false)}; } }">
     </div>
     </div>
   </div>
   </div>
 
 
-  <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults()">
+  <div class="widget-spinner" data-bind="visible: isLoading()">
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
     <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
   </div>
   </div>

+ 3 - 1
desktop/core/src/desktop/static/desktop/js/ko.charts.js

@@ -346,7 +346,9 @@ ko.bindingHandlers.leafletMapChart = {
       }
       }
       else {
       else {
         $(element).hide();
         $(element).hide();
-        $(element).before($("<div>").addClass("leaflet-nodata").css("textAlign", "center").text("No Data Available."));
+        if ((_options.visible != null && _options.visible) && !_options.isLoading){
+          $(element).before($("<div>").addClass("leaflet-nodata").css("textAlign", "center").text("No Data Available."));
+        }
       }
       }
 
 
       var _map = null;
       var _map = null;