Browse Source

HUE-7067 [dashboard] Refresh facet result when reordering sub-facets

Romain Rigaux 8 years ago
parent
commit
9c89076d80

+ 8 - 5
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -507,7 +507,7 @@ var Collection = function (vm, collection) {
     if (val == 'fixed'){
       self.autorefresh(false);
     }
-	  if (val == 'fixed' && self.timeFilter.from().length == 0) {
+    if (val == 'fixed' && self.timeFilter.from().length == 0) {
       $.ajax({
         type: "POST",
         url: "/dashboard/get_range_facet",
@@ -650,6 +650,11 @@ var Collection = function (vm, collection) {
         vm.search();
       });
     }
+    if (facet.properties.facets) {
+      facet.properties.facets.subscribe(function(newValue) {
+        vm.search();
+      });
+    }
 
     // For Hue 4 facets only
     if (typeof facet.template != 'undefined') {
@@ -712,6 +717,7 @@ var Collection = function (vm, collection) {
         vm.search();
       });
     }
+
     if (typeof facet.properties.facets != 'undefined') {
       $.each(facet.properties.facets(), function (index, pivotFacet) {
         if (pivotFacet.aggregate && pivotFacet.aggregate.function) {
@@ -723,6 +729,7 @@ var Collection = function (vm, collection) {
     }
   });
 
+
   self.template.rows.subscribe(function() {
     vm.search();
   });
@@ -892,7 +899,6 @@ var Collection = function (vm, collection) {
         vm.search();
       });
       facet.properties.facets.push(pivot);
-      vm.search();
     }
   }
 
@@ -920,14 +926,11 @@ var Collection = function (vm, collection) {
         vm.search();
       });
       facet.properties.facets.push(pivot);
-      vm.search();
     }
   }
 
   self.removePivotFacetValue = function(facet) {
     facet['pivot_facet'].properties.facets.remove(facet['value']);
-
-    vm.search();
   }
 
   self.removeFacet = function (widget_id) {