Browse Source

[search] Select a place on map and create a filter

Romain Rigaux 11 years ago
parent
commit
68bc031

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

@@ -807,10 +807,10 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
       </span>
     </div>
     <div data-bind="with: $root.collection.getFacetById($parent.id())">
-      <div data-bind="mapChart: {data: {counts: $parent.counts, widget_id: $parent.id, scope: $root.collection.getFacetById($parent.id).properties.scope()},
+      <div data-bind="mapChart: {data: {counts: $parent.counts, scope: $root.collection.getFacetById($parent.id).properties.scope()},
         transformer: mapChartDataTransformer,
         maxWidth: 750,
-        onClick: function(d){ console.log(d); },
+        onClick: function(d){ viewModel.query.toggleFacet({facet: d, widget_id: $parent.id}) },
         onComplete: function(){ viewModel.getWidgetById($parent.id).isLoading(false)} }" />
     </div>
   </div>
@@ -1387,7 +1387,6 @@ function timelineChartDataTransformer(rawDatum) {
 function mapChartDataTransformer(data) {
   var _data = [];
   $(data.counts).each(function (cnt, item) {
-    item.widget_id = data.widget_id;
     _data.push({
       label: item.value,
       value: item.count,

+ 1 - 1
apps/search/static/js/charts.ko.js

@@ -147,7 +147,7 @@ ko.bindingHandlers.mapChart = {
         if (_place != null){
           _mapdata[_place] = {
             fillKey: "fill_" + Math.floor(item.value / _chunk),
-            id: _place
+            id: _place,
           };
           _maphovers[_place] = item.value;
         }

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

@@ -256,7 +256,7 @@ var Query = function (vm, query) {
     self.qs.remove(query);
   };
   
-  self.toggleFacet = function (data) {
+  self.toggleFacet = function (data) { alert(ko.mapping.toJSON(data));
     var fq = self.getFacetFilter(data.widget_id);
 
     if (fq == null) {