Browse Source

HUE-2173 [search] Add range to nested text facet

Romain Rigaux 9 years ago
parent
commit
757324b33a

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

@@ -49,7 +49,7 @@ def _compute_range_facet(widget_type, stat_facet, properties, start=None, end=No
 
 
     if widget_type == 'pie-widget' or widget_type == 'pie2-widget':
     if widget_type == 'pie-widget' or widget_type == 'pie2-widget':
       SLOTS = 5
       SLOTS = 5
-    elif widget_type == 'facet-widget':
+    elif widget_type == 'facet-widget' or widget_type == 'text-facet-widget':
       SLOTS = 10
       SLOTS = 10
     else:
     else:
       SLOTS = 100
       SLOTS = 100

+ 2 - 2
apps/search/src/search/models.py

@@ -812,8 +812,8 @@ def augment_solr_response(response, collection, query):
         extraSeries = []
         extraSeries = []
         counts = response['facets'][name]['buckets']
         counts = response['facets'][name]['buckets']
 
 
-        # Date range
-        if collection_facet['properties']['isDate']:
+        # Number or Date range
+        if collection_facet['properties']['canRange']:
           dimension = 3
           dimension = 3
           # Single dimension or dimension 2 with analytics
           # Single dimension or dimension 2 with analytics
           if not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate'] not in ('count', 'unique'):
           if not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate'] not in ('count', 'unique'):

+ 20 - 18
apps/search/src/search/templates/common_search.mako

@@ -505,15 +505,18 @@ ${ dashboard.layout_skeleton() }
 <script type="text/html" id="facet-toggle2">
 <script type="text/html" id="facet-toggle2">
 
 
     ## Dimension 1
     ## Dimension 1
-   <div class="facet-field-cnt" data-bind="visible: properties.canRange">
+    <!-- ko if: properties.canRange -->
+    <div class="facet-field-cnt">
       <span class="facet-field-label facet-field-label-fixed-width">${ _('Type') }</span>
       <span class="facet-field-label facet-field-label-fixed-width">${ _('Type') }</span>
       <a href="javascript: void(0)" title="${ _('Toggle how to group the values') }" data-bind="click: $root.collection.toggleRangeFacet">
       <a href="javascript: void(0)" title="${ _('Toggle how to group the values') }" data-bind="click: $root.collection.toggleRangeFacet">
-        <i class="fa" data-bind="css: { 'fa-arrows-h': type() == 'range', 'fa-circle': type() == 'field', 'fa-level-up': type() == 'range-up' }, attr: { title: type() == 'field' ? 'Range' : type() == 'range-up' ? 'Range and up' : 'Term' }"></i>
+        <i class="fa" data-bind="css: { 'fa-arrows-h': properties.type() == 'range', 'fa-circle': properties.type() == 'field', 'fa-level-up': properties.type() == 'range-up' }, attr: { title: properties.type() == 'field' ? 'Range' : properties.type() == 'range-up' ? 'Range and up' : 'Term' }"></i>
         <span data-bind="visible: type() == 'range'">${_('range')}</span>
         <span data-bind="visible: type() == 'range'">${_('range')}</span>
         <span data-bind="visible: type() == 'range-up'">${_('range & up')}</span>
         <span data-bind="visible: type() == 'range-up'">${_('range & up')}</span>
         <span data-bind="visible: type() == 'field'">${_('field')}</span>
         <span data-bind="visible: type() == 'field'">${_('field')}</span>
       </a>
       </a>
     </div>
     </div>
+    <!-- /ko -->
+
     <div class="facet-field-cnt">
     <div class="facet-field-cnt">
       <span class="facet-field-label facet-field-label-fixed-width">${ _('Sorting') }</span>
       <span class="facet-field-label facet-field-label-fixed-width">${ _('Sorting') }</span>
       <a href="javascript: void(0)" title="${ _('Toggle sort order') }" data-bind="click: $root.collection.toggleSortFacet">
       <a href="javascript: void(0)" title="${ _('Toggle sort order') }" data-bind="click: $root.collection.toggleSortFacet">
@@ -533,24 +536,23 @@ ${ dashboard.layout_skeleton() }
       <!-- /ko -->
       <!-- /ko -->
     <!-- /ko -->
     <!-- /ko -->
 
 
-    
-      <div class="facet-field-cnt">
-        <span class="spinedit-cnt">
-          <span class="facet-field-label facet-field-label-fixed-width">
-            ${ _('Limit') }
-          </span>
-          <input type="text" class="input-medium" data-bind="spinedit: properties.limit"/>
+    <div class="facet-field-cnt">
+      <span class="spinedit-cnt">
+        <span class="facet-field-label facet-field-label-fixed-width">
+          ${ _('Limit') }
         </span>
         </span>
-      </div>
-    
-      <div class="facet-field-cnt">
-        <span class="spinedit-cnt">
-          <span class="facet-field-label">
-            ${ _('Min Count') }
-          </span>
-          <input type="text" class="input-medium" data-bind="spinedit: properties.mincount"/>
+        <input type="text" class="input-medium" data-bind="spinedit: properties.limit"/>
+      </span>
+    </div>
+  
+    <div class="facet-field-cnt">
+      <span class="spinedit-cnt">
+        <span class="facet-field-label">
+          ${ _('Min Count') }
         </span>
         </span>
-      </div>
+        <input type="text" class="input-medium" data-bind="spinedit: properties.mincount"/>
+      </span>
+    </div>
 
 
   ## Dimensions > 1
   ## Dimensions > 1
   <!-- ko if: $root.isEditing -->  
   <!-- ko if: $root.isEditing -->  

+ 0 - 1
desktop/libs/libsolr/src/libsolr/api.py

@@ -302,7 +302,6 @@ class SolrApi(object):
       timeFilter = self._get_range_borders(collection, query)
       timeFilter = self._get_range_borders(collection, query)
 
 
       for facet in collection['facets']:
       for facet in collection['facets']:
-        print facet
         if facet['type'] == 'query':
         if facet['type'] == 'query':
           params += (('facet.query', '%s' % facet['field']),)
           params += (('facet.query', '%s' % facet['field']),)
         elif facet['type'] == 'range' or facet['type'] == 'range-up':
         elif facet['type'] == 'range' or facet['type'] == 'range-up':