Ver Fonte

[search] Fix for delete facet

Enrico Berti há 11 anos atrás
pai
commit
bc88af6

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

@@ -253,8 +253,8 @@ ${ commonheader(_('Search'), "search", user, "60px") | n,unicode }
 
   <!-- ko if: $root.getFacetFromQuery(id()) -->
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
-    <div data-bind="visible: $root.isEditing, template: {data: $root.collection.getFacetById($parent.id()), afterRender: function(){ $parent.isLoading(false);}}" style="margin-bottom: 20px">
-      <span data-bind="template: { name: 'facet-toggle' }">
+    <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
+      <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id).isLoading(false); } }">
       </span>
     </div>
     <div data-bind="with: $root.collection.getFacetById($parent.id())">

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

@@ -231,7 +231,9 @@ function barChart(element, options, isTimeline) {
     var _chart;
     if (isTimeline) {
       _chart = nv.models.multiBarWithBrushChart();
-      //_chart.enableSelection();
+      if (_datum.length > 0 && _datum[0].values.length > 10){
+        _chart.enableSelection();
+      }
       _chart.onSelectRange(options.onSelectRange);
       _chart.xAxis
           .showMaxMin(true)

+ 10 - 5
apps/search/static/js/nv.d3.multiBarWithBrushChart.js

@@ -116,10 +116,10 @@ nv.models.multiBarWithBrushChart = function() {
       chart.update = function() {
         container.transition().duration(transitionDuration).call(chart)
         if (selectionEnabled){
-          enableSelection();
+          enableBrush();
         }
         else {
-          disableSelection();
+          disableBrush();
         }
       };
       chart.container = this;
@@ -265,11 +265,11 @@ nv.models.multiBarWithBrushChart = function() {
       //------------------------------------------------------------
       // Setup Brush
       if (selectionEnabled){
-        enableSelection();
+        enableBrush();
       }
 
 
-      function enableSelection() {
+      function enableBrush() {
         if (g.selectAll('.nv-brush')[0].length == 0) {
           gEnter.append('g').attr('class', 'nv-brushBackground');
           gEnter.append('g').attr('class', 'nv-x nv-brush');
@@ -306,7 +306,7 @@ nv.models.multiBarWithBrushChart = function() {
         }
       }
 
-      function disableSelection() {
+      function disableBrush() {
         g.selectAll('.nv-brush').attr('display', 'none');
       }
 
@@ -637,6 +637,11 @@ nv.models.multiBarWithBrushChart = function() {
     return chart;
   };
 
+  chart.enableSelection = function() {
+    selectionEnabled = true;
+    return chart;
+  };
+
   chart.onSelectRange = function(_) {
     if (!arguments.length) return onSelectRange;
     onSelectRange = _;

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

@@ -74,7 +74,7 @@ var Row = function (widgets) {
 }
 
 // A widget is generic. It has an id that refer to another object (e.g. facet) with the same id.
-var Widget = function (size, id, name, widgetType, properties, offset) {
+var Widget = function (size, id, name, widgetType, properties, offset, loading) {
   var self = this;
   self.size = ko.observable(size).extend({ numeric: 0 });
 
@@ -83,7 +83,7 @@ var Widget = function (size, id, name, widgetType, properties, offset) {
   self.widgetType = ko.observable(typeof widgetType != "undefined" && widgetType != null ? widgetType : "empty-widget");
   self.properties = ko.observable(typeof properties != "undefined" && properties != null ? properties : {});
   self.offset = ko.observable(typeof offset != "undefined" && offset != null ? offset : 0).extend({ numeric: 0 });
-  self.isLoading = ko.observable(true);
+  self.isLoading = ko.observable(typeof loading != "undefined" && loading != null ? loading : false);
 
 
   self.klass = ko.computed(function () {
@@ -179,7 +179,7 @@ function loadLayout(viewModel, json_layout) {
     $(json_col.rows).each(function (rcnt, json_row) {
       var row = new Row();
       $(json_row.widgets).each(function (wcnt, widget) {
-        row.addWidget(new Widget(widget.size, widget.id, widget.name, widget.widgetType, widget.properties, widget.offset));
+        row.addWidget(new Widget(widget.size, widget.id, widget.name, widget.widgetType, widget.properties, widget.offset, true));
       });
       _rows.push(row);
     });