Переглянути джерело

HUE-5212 [metadata] Harmonize result description display and highlighting

Romain Rigaux 9 роки тому
батько
коміт
0137696e57

+ 0 - 6
desktop/core/src/desktop/templates/assist.mako

@@ -1208,13 +1208,7 @@ from metadata.conf import has_navigator
             <!-- ko if: typeof click === 'undefined' -->
             <a class="pointer" data-bind="attr: { 'href': link }, text: originalName" target="_blank" ></a>
             <!-- /ko -->
-            <div class="nav-search-tags" data-bind="foreach: tags">
-              <div data-bind="text: $data"></div>
-            </div>
             <div class="doc-desc" data-bind="html: hue_description"></div>
-            <!-- ko if: hasDescription && ! hue_description -->
-              <div class="doc-desc" data-bind="text: originalDescription"></div>
-            <!-- /ko -->
           </div>
         </div>
       </div>

+ 9 - 4
desktop/libs/metadata/src/metadata/navigator_api.py

@@ -243,9 +243,10 @@ def _augment_highlighting(query_s, records):
         ts.append(term.strip('*'))
 
   for record in records:
+    name = record.get('originalName', '')
     record['hue_description'] = ''
     record['hue_name'] = (record.get('parentPath', '').replace('/', '.') + '.').lstrip('.')
-    name = record.get('originalName', '')
+
     for term in ts:
       name = _highlight(term, name)
       if record.get('tags'):
@@ -257,6 +258,10 @@ def _augment_highlighting(query_s, records):
         else:
           record['hue_description'] += ' %s:%s' % (fname, _highlight(fval, record[fname]))
 
+    originalDescription = record.get('originalDescription', '')
+    if not record['hue_description'] and originalDescription:
+      record['hue_description'] = _highlight(term, originalDescription)
+
     record['hue_name'] += name
     record['hue_name'] = escape(record['hue_name']).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>')
     record['hue_description'] = escape(record['hue_description']).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>')
@@ -267,9 +272,9 @@ def _highlight(pattern, string):
 
 
 def _highlight_tags(record, term):
-    for tag in record['tags']:
-      if re.match(term, tag):
-        record['hue_description'] += ' tags:%s' % _highlight(term, tag)
+  for tag in record['tags']:
+    if re.match(term, tag):
+      record['hue_description'] += ' tags:%s' % _highlight(term, tag)
 
 
 @error_handler