Browse Source

HUE-7832 [assist] Allow filtering in the document types drop-down

Johan Ahlen 8 years ago
parent
commit
26f8443

+ 1 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -640,7 +640,7 @@ from desktop.views import _ko
   <script type="text/html" id="assist-document-header-actions">
     <div class="assist-db-header-actions">
       <!-- ko if: !loading() -->
-      <div class="highlightable" data-bind="css: { 'highlight': $parent.highlightTypeFilter() }, component: { name: 'hue-drop-down', params: { fixedPosition: true, value: typeFilter, entries: DOCUMENT_TYPES, linkTitle: '${ _ko('Document type') }' } }" style="display: inline-block"></div>
+      <div class="highlightable" data-bind="css: { 'highlight': $parent.highlightTypeFilter() }, component: { name: 'hue-drop-down', params: { fixedPosition: true, value: typeFilter, searchable: true, entries: DOCUMENT_TYPES, linkTitle: '${ _ko('Document type') }' } }" style="display: inline-block"></div>
       <!-- /ko -->
       <a class="inactive-action" href="javascript:void(0)" data-bind="click: function () { huePubSub.publish('assist.document.refresh'); }"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }" title="${_('Manual refresh')}"></i></a>
     </div>

+ 10 - 3
desktop/core/src/desktop/templates/ko_components/ko_drop_down.mako

@@ -35,7 +35,7 @@ from desktop.views import _ko
     </a>
     <!-- /ko -->
     <!-- ko if: !menuOnly && (dropDownVisible() && searchable) -->
-    <input class="hue-drop-down-input" type="text" data-bind="textInput: filter, attr: { 'placeHolder': value }, visible: dropDownVisible, style: { color: filterEdited() ? '#000' : '#AAA', 'min-height': '22px', 'margin-left': '10px' }"/>
+    <input class="hue-drop-down-input" type="text" data-bind="textInput: filter, attr: { 'placeHolder': inputPlaceHolder }, visible: dropDownVisible, style: { color: filterEdited() ? '#000' : '#AAA', 'min-height': '22px', 'margin-left': '10px' }"/>
     <i class="fa fa-caret-down"></i>
     <!-- /ko -->
     <div class="hue-drop-down-container" data-bind="css: { 'open' : dropDownVisible, 'hue-drop-down-fixed': fixedPosition }">
@@ -79,6 +79,10 @@ from desktop.views import _ko
         self.linkTitle = params.linkTitle || '${ _('Selected entry') }';
         self.fixedPosition = !!params.fixedPosition;
 
+        self.inputPlaceHolder = ko.pureComputed(function () {
+          return typeof self.value() === 'object' ? self.value().label : self.value();
+        });
+
         var closeOnOutsideClick = function (e) {
           var $input = $(element).find('.hue-drop-down-input');
           if (!$input.is($(e.target))) {
@@ -160,8 +164,11 @@ from desktop.views import _ko
             return ko.unwrap(self.entries);
           } else {
             var lowerFilter = self.filter().toLowerCase();
-            return ko.unwrap(self.entries).filter(function (database) {
-              return database.toLowerCase().indexOf(lowerFilter) !== -1;
+            return ko.unwrap(self.entries).filter(function (entry) {
+              if (typeof entry === 'object') {
+                return entry.label.toLowerCase().indexOf(lowerFilter) !== -1;
+              }
+              return entry.toLowerCase().indexOf(lowerFilter) !== -1;
             });
           }
         });