浏览代码

HUE-3706 [search] Expanding a document should expand the field list too

Enrico Berti 9 年之前
父节点
当前提交
5f13846
共有 2 个文件被更改,包括 16 次插入8 次删除
  1. 4 1
      apps/search/src/search/static/search/js/search.ko.js
  2. 12 7
      apps/search/src/search/templates/search.mako

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

@@ -1643,7 +1643,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
     });
   }
 
-  self.getDocument = function (doc) {
+  self.getDocument = function (doc, callback) {
     $.post("/search/get_document", {
       collection: ko.mapping.toJSON(self.collection),
       id: doc.id
@@ -1678,6 +1678,9 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
       }
       doc.details(details);
       doc.originalDetails(ko.toJSON(doc.details()));
+      if (callback) {
+        callback(details);
+      }
     }, "text").fail(function (xhr, textStatus, errorThrown) {
       $(document).trigger("error", xhr.responseText);
     });

+ 12 - 7
apps/search/src/search/templates/search.mako

@@ -2624,13 +2624,6 @@ function multiSerieDataTransformerGrid(rawDatum) {
   return _datum;
 }
 
-function toggleDocDetails(doc) {
-  doc.showDetails(! doc.showDetails());
-
-  if (doc.details().length == 0) {
-    viewModel.getDocument(doc);
-  }
-}
 
 function resizeFieldsList() {
   $(".fields-list").css("max-height", Math.max($("#result-container").height(), 230));
@@ -2643,6 +2636,18 @@ function resizeFieldsList() {
   }, 100);
 }
 
+function toggleDocDetails(doc) {
+  doc.showDetails(! doc.showDetails());
+
+  if (doc.details().length == 0) {
+    viewModel.getDocument(doc, resizeFieldsList);
+  }
+  else {
+    window.setTimeout(resizeFieldsList, 0);
+  }
+}
+
+
 function queryTypeahead(query, process) {
   var _source = viewModel.collection.template.fieldsNames();
   _source = _source.concat("AND OR TO".split(" "))