Эх сурвалжийг харах

[search] Field list adjust its height to the result panel

Enrico Berti 11 жил өмнө
parent
commit
4a87d552f0

+ 18 - 1
apps/search/src/search/templates/search2.mako

@@ -428,7 +428,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
           </a>
         </div>
         <input type="text" data-bind="value: $root.collection.template.fieldsAttributesFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" style="width: 88%; margin-bottom: 3px" />
-        <div data-bind="foreach: $root.collection.template.filteredAttributeFields" style="max-height: 230px; overflow-y: auto">
+        <div class="fields-list" data-bind="foreach: $root.collection.template.filteredAttributeFields" style="max-height: 230px; overflow-y: auto">
           <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" /> 
           <span data-bind="text: '&nbsp;' + name()"></span>
           <br/>
@@ -1407,8 +1407,20 @@ function toggleDocDetails(doc){
   }
 }
 
+function resizeFieldsList() {
+  $(".fields-list").css("max-height", Math.max($("#result-container").height(), 230));
+}
+
 $(document).ready(function () {
 
+  var _resizeTimeout = -1;
+  $(window).resize(function(){
+    window.clearTimeout(_resizeTimeout);
+    window.setTimeout(function(){
+      resizeFieldsList();
+    }, 200);
+  });
+
   $(document).on("showDoc", function(e, doc){
     viewModel.collection.selectedDocument(doc);
     var _docDetailsRow = $("#doc_" + doc[viewModel.collection.idField()] + "_details");
@@ -1674,6 +1686,11 @@ $(document).ready(function () {
   viewModel.init(function(data){
     $(".chosen-select").trigger("chosen:updated");
   });
+  viewModel.isRetrievingResults.subscribe(function(value){
+    if (!value){
+      resizeFieldsList();
+    }
+  });
 });
 
   function toggleGridFieldsSelection() {