Sfoglia il codice sorgente

[search] Ask only for the used fields in the gridlayout

Romain Rigaux 11 anni fa
parent
commit
3ae84c6

+ 4 - 4
apps/search/src/search/api.py

@@ -123,10 +123,10 @@ class SolrApi(object):
     for fq, val in fqs.iteritems():
       params += (('fq', urllib.unquote(utf_quoter('{!tag=%s}{!field f=%s}%s' % (fq, fq, val)))),)
 
-#    if collection['template']['fields']:
-      # If we do this, need to parse the template and fill up the fields list
-      #params += (('fl', urllib.unquote(utf_quoter(','.join(collection['fields'])))),)
-    params += (('fl', '*'),)
+    if collection['template']['fieldsSelected'] and collection['template']['isGridLayout']:
+      params += (('fl', urllib.unquote(utf_quoter(','.join(collection['template']['fieldsSelected'])))),)
+    else:
+      params += (('fl', '*'),)
 
     params += (
       ('hl', 'true'),

+ 9 - 4
apps/search/src/search/templates/search2.mako

@@ -199,7 +199,7 @@ ${ commonheader(_('Search'), "search", user, "60px") | n,unicode }
     <!-- <div class="draggable-widget" data-bind="draggable: draggableHit" title="${_('Hit Count')}" rel="tooltip" data-placement="top"><a href="#"><i class="fa fa-tachometer"></i></a></div> -->
     <div class="draggable-widget" data-bind="draggable: draggableBar" title="${_('Bar Chart')}" rel="tooltip" data-placement="top"><a href="#"><i class="hcha hcha-bar-chart"></i></a></div>
     <div class="draggable-widget" data-bind="draggable: draggableHistogram" title="${_('Timeline')}" rel="tooltip" data-placement="top"><a href="#"><i class="fa fa-long-arrow-right"></i></a></div>
-    <div class="draggable-widget" data-bind="draggable: draggableLine" title="${_('Filter Bar')}" rel="tooltip" data-placement="top"><a href="#"><i class="fa fa-filter"></i></a></div>
+    <div class="draggable-widget" data-bind="draggable: draggableFilter" title="${_('Filter Bar')}" rel="tooltip" data-placement="top"><a href="#"><i class="fa fa-filter"></i></a></div>
     <div class="draggable-widget" data-bind="draggable: draggableMap" title="${_('Map')}" rel="tooltip" data-placement="top"><a href="#"><i class="hcha hcha-map-chart"></i></a></div>    
   </div>
   <div class="clearfix"></div>
@@ -334,7 +334,12 @@ ${ commonheader(_('Search'), "search", user, "60px") | n,unicode }
     <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">      
       ${ _('Label') }: <input type="text" data-bind="value: label" />
       ${ _('Field') }: <input type="text" data-bind="value: field" />
-      <br/>
+      <!-- ko if: type() == 'range' -->
+        <br/>
+        ${ _('Start') }: <input type="text" data-bind="value: properties.start" />
+        ${ _('End') }: <input type="text" data-bind="value: properties.end" />
+        ${ _('Gap') }: <input type="text" data-bind="value: properties.gap" />
+      <!-- /ko -->
       <span>
         <span data-bind="text: label" style="font-weight: bold"></span>
         <a href="javascript: void(0)" class="btn btn-loading" data-bind="click: $root.collection.toggleFacet" data-loading-text="...">      
@@ -516,8 +521,8 @@ ${ commonheader(_('Search'), "search", user, "60px") | n,unicode }
   This is the area widget
 </script>
 
-<script type="text/html" id="line-widget">
-  This is the line widget
+<script type="text/html" id="filter-widget">
+  
 </script>
 
 <script type="text/html" id="map-widget">

+ 1 - 0
apps/search/static/js/search.ko.js

@@ -377,6 +377,7 @@ var SearchViewModel = function (collection_json, query_json) {
   self.draggableMap = ko.observable(new Widget(12, UUID(), "Map", "map-widget"));
   self.draggableLine = ko.observable(new Widget(12, UUID(), "Line Chart", "line-widget"));
   self.draggablePie = ko.observable(new Widget(12, UUID(), "Pie Chart", "pie-widget"));
+  self.draggableFilter = ko.observable(new Widget(12, UUID(), "Filter Bar", "filter-widget"));  
 
   self.init = function () {
   //self.collection.addDynamicFields();