ソースを参照

HUE-6977 [editor] Fix issue where the autocomplete dropdown doesn't show for column completion

Johan Ahlen 8 年 前
コミット
96c946738c

+ 25 - 21
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter3.js

@@ -636,38 +636,42 @@ var AutocompleteResults = (function () {
         // For multiple tables we need to merge and make sure identifiers are unique
         var columnDeferrals = [];
 
+        var waitForCols = function () {
+          $.when.apply($, columnDeferrals).always(function () {
+            self.mergeColumns(columnSuggestions);
+            if (self.snippet.type() === 'hive' && /[^\.]$/.test(self.editor().getTextBeforeCursor())) {
+              columnSuggestions.push({
+                value: 'BLOCK__OFFSET__INSIDE__FILE',
+                meta: AutocompleterGlobals.i18n.meta.virtual,
+                category: CATEGORIES.VIRTUAL_COLUMN,
+                popular: ko.observable(false),
+                details: null
+              });
+              columnSuggestions.push({
+                value: 'INPUT__FILE__NAME',
+                meta: AutocompleterGlobals.i18n.meta.virtual,
+                category: CATEGORIES.VIRTUAL_COLUMN,
+                popular: ko.observable(false),
+                details: null
+              });
+            }
+            columnsDeferred.resolve(columnSuggestions);
+          });
+        };
+
         if (suggestColumns.types && suggestColumns.types[0] === 'COLREF') {
           colRefDeferred.done(function (colRef) {
             suggestColumns.tables.forEach(function (table) {
               columnDeferrals.push(self.addColumns(table, [colRef.type.toUpperCase()], columnSuggestions));
             });
+            waitForCols();
           });
         } else {
           suggestColumns.tables.forEach(function (table) {
             columnDeferrals.push(self.addColumns(table, suggestColumns.types || ['T'], columnSuggestions));
           });
+          waitForCols();
         }
-
-        $.when.apply($, columnDeferrals).always(function () {
-          self.mergeColumns(columnSuggestions);
-          if (self.snippet.type() === 'hive' && /[^\.]$/.test(self.editor().getTextBeforeCursor())) {
-            columnSuggestions.push({
-              value: 'BLOCK__OFFSET__INSIDE__FILE',
-              meta: AutocompleterGlobals.i18n.meta.virtual,
-              category: CATEGORIES.VIRTUAL_COLUMN,
-              popular: ko.observable(false),
-              details: null
-            });
-            columnSuggestions.push({
-              value: 'INPUT__FILE__NAME',
-              meta: AutocompleterGlobals.i18n.meta.virtual,
-              category: CATEGORIES.VIRTUAL_COLUMN,
-              popular: ko.observable(false),
-              details: null
-            });
-          }
-          columnsDeferred.resolve(columnSuggestions);
-        });
       } else {
         columnsDeferred.reject();
       }

+ 2 - 2
desktop/core/src/desktop/templates/hue_ace_autocompleter.mako

@@ -21,7 +21,7 @@ from desktop.views import _ko
 
 <%def name="hueAceAutocompleter()">
   <script type="text/html" id="hue-ace-autocompleter">
-    <!-- ko if: active() && suggestions.filtered().length !== 0 -->
+    <!-- ko if: active() && (suggestions.filtered().length !== 0 || suggestions.loading()) -->
     <div class="hue-ace-autocompleter" data-bind="style: { top: top() + 'px', left: left() + 'px' }, event: { mousewheel: function (data, event) { event.stopPropagation(); }}">
       <div class="autocompleter-suggestions">
         <!-- ko if: suggestions.availableCategories().length > 1 || suggestions.loading() -->
@@ -436,7 +436,7 @@ from desktop.views import _ko
 
         var autocompleterDoneSub = huePubSub.subscribe('hue.ace.autocompleter.done', function () {
           window.setTimeout(function () {
-            if (self.active() && self.suggestions.filtered().length === 0) {
+            if (self.active() && self.suggestions.filtered().length === 0 && !self.suggestions.loading()) {
               self.detach();
             }
           }, 0);