瀏覽代碼

HUE-5667 [metadata] Show assist search results on click

Johan Ahlen 8 年之前
父節點
當前提交
3c2021e

+ 21 - 5
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -140,9 +140,18 @@
       if (options.closeOnEnter || options.onEnter || options.blurOnEnter) {
         $element.on('keyup', function (e) {
           if(e.which === 13) {
+            if (options.reopenPattern && options.reopenPattern.test($element.val())) {
+              window.setTimeout(function () {
+                $element.hueAutocomplete('search', $element.val());
+              }, 0);
+              return;
+            }
             if (options.closeOnEnter) {
               $element.hueAutocomplete('close');
             }
+            if (options.valueObservable) {
+              options.valueObservable($element.val());
+            }
             if (options.onEnter) {
               options.onEnter();
             }
@@ -183,16 +192,23 @@
         closeSubscription.remove();
       });
 
-      if (options.reopenPattern) {
+      if (options.reopenPattern || options.valueObservable || options.onSelect) {
         var oldSelect = options.select;
         options.select = function (event, ui) {
-          if (oldSelect) {
-            oldSelect(event, ui);
-          }
-          if (options.reopenPattern.test(ui.item.value)) {
+          if (options.reopenPattern && options.reopenPattern.test(ui.item.value)) {
             window.setTimeout(function () {
               $element.hueAutocomplete('search', $element.val());
             }, 0);
+            return;
+          }
+          if (options.valueObservable) {
+            options.valueObservable(ui.item.value);
+          }
+          if (options.onSelect) {
+            options.onSelect();
+          }
+          if (oldSelect) {
+            oldSelect(event, ui);
           }
         };
       }

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

@@ -1210,6 +1210,8 @@ from notebook.conf import ENABLE_QUERY_BUILDER
           classPrefix: 'nav-',
           showOnFocus: true,
           onEnter: performSearch,
+          valueObservable: searchInput,
+          onSelect: performSearch,
           reopenPattern: /.*:$/
         },
         hasFocus: searchHasFocus,