Browse Source

[search] Reset result cache when changing result widget

Romain Rigaux 10 years ago
parent
commit
2328e99524

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

@@ -411,6 +411,7 @@ var Collection = function (vm, collection) {
   });
   self.template.isGridLayout.subscribe(function () {
     vm.results.removeAll();
+    vm.resultsHash = '';
     vm.search();
   });
   if (self.template.leafletmap.latitudeField == undefined) {
@@ -1163,7 +1164,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
         else {
           var _resultsHash = ko.mapping.toJSON(data.response.docs);
 
-          if (self._resultsHash != _resultsHash) {
+          if (self.resultsHash != _resultsHash) {
             if (self.collection.template.isGridLayout()) {
               // Table view
               var _docs = [];
@@ -1213,7 +1214,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
               self.results(_docs);
             }
           }
-          self._resultsHash = _resultsHash;
+          self.resultsHash = _resultsHash;
         }
       })
       ].concat(multiQs)

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

@@ -678,7 +678,7 @@ ${ dashboard.layout_skeleton() }
         <div class="result-row" data-bind="html: $data"></div>
       </div>
 
-      <div class="widget-spinner" data-bind="visible: ! hasRetrievedResults()">
+      <div class="widget-spinner" data-bind="visible: ! $root.hasRetrievedResults()">
         <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
         <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }" /><![endif]-->
       </div>