浏览代码

HUE-7348 [search] Do not error when loading a non analytics saved dashboard

Romain Rigaux 8 年之前
父节点
当前提交
802f872
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

+ 6 - 4
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -658,10 +658,12 @@ var Collection = function (vm, collection) {
   }
 
   self._addObservablesToFacet = function(facet, vm) {
-    facet.properties.facets_form.metrics = ko.computed(function() {
-      var _field = self.getTemplateField(facet.widgetType() == 'hit-widget' ? facet.field() : facet.properties.facets_form.field(), self.template.fieldsAttributes());
-      return self._get_field_operations(_field, facet);
-    });
+    if (facet.properties.facets_form) { // Only Solr 5+
+	  facet.properties.facets_form.metrics = ko.computed(function() {
+        var _field = self.getTemplateField(facet.widgetType() == 'hit-widget' ? facet.field() : facet.properties.facets_form.field(), self.template.fieldsAttributes());
+        return self._get_field_operations(_field, facet);
+      });
+    }
 
     facet.properties.limit.subscribe(function () {
       vm.search();