Sfoglia il codice sorgente

HUE-2330 [beeswax] Collapse previously expanded tables on assist

Added support for expanding/collapsing on all the Assists
Enrico Berti 11 anni fa
parent
commit
a2b0511

+ 18 - 13
apps/beeswax/src/beeswax/templates/execute.mako

@@ -1128,22 +1128,27 @@ $(document).ready(function () {
 
             _table.data("table", table).attr("id", "navigatorTables_" + table);
             _table.find("a:eq(2)").on("click", function () {
-              _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");
-              hac_getTableColumns(viewModel.database(), table, "", function (plain_columns, extended_columns) {
-                _table.find("a:eq(1)").removeClass("hide");
+              if (_table.find("li").length > 0){
                 _table.find("ul").empty();
-                _table.find(".fa-spinner").removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-table");
-                $(extended_columns).each(function (iCnt, col) {
-                  var _column = $("<li>");
-                  _column.html("<a href='javascript:void(0)' style='padding-left:10px'" + (col.comment != null && col.comment != "" ? " title='" + col.comment + "'" : "") + "><i class='fa fa-columns'></i> " + col.name + ($.trim(col.type) != "" ? " (" + $.trim(col.type) + ")" : "") + "</a>");
-                  _column.appendTo(_table.find("ul"));
-                  _column.on("dblclick", function () {
-                    codeMirror.replaceSelection($.trim(col.name) + ', ');
-                    codeMirror.setSelection(codeMirror.getCursor());
-                    codeMirror.focus();
+              }
+              else {
+                _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");
+                hac_getTableColumns(viewModel.database(), table, "", function (plain_columns, extended_columns) {
+                  _table.find("a:eq(1)").removeClass("hide");
+                  _table.find("ul").empty();
+                  _table.find(".fa-spinner").removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-table");
+                  $(extended_columns).each(function (iCnt, col) {
+                    var _column = $("<li>");
+                    _column.html("<a href='javascript:void(0)' style='padding-left:10px'" + (col.comment != null && col.comment != "" ? " title='" + col.comment + "'" : "") + "><i class='fa fa-columns'></i> " + col.name + ($.trim(col.type) != "" ? " (" + $.trim(col.type) + ")" : "") + "</a>");
+                    _column.appendTo(_table.find("ul"));
+                    _column.on("dblclick", function () {
+                      codeMirror.replaceSelection($.trim(col.name) + ', ');
+                      codeMirror.setSelection(codeMirror.getCursor());
+                      codeMirror.focus();
+                    });
                   });
                 });
-              });
+              }
             });
             _table.find("a:eq(2)").on("dblclick", function () {
               codeMirror.replaceSelection($.trim(table) + ' ');

+ 20 - 15
apps/rdbms/src/rdbms/templates/execute.mako

@@ -718,23 +718,28 @@ ${ commonheader(_('Query'), app_name, user) | n,unicode }
             codeMirror.focus();
           });
           _table.find("a").on("click", function () {
-            _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");
-            rdbms_getTableColumns(viewModel.server().name(), viewModel.database(), table, "", function (columns) {
+            if (_table.find("li").length > 0){
               _table.find("ul").empty();
-              _table.find(".fa-spinner").removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-table");
-              $(columns.split(" ")).each(function (iCnt, col) {
-                if ($.trim(col) != "" && $.trim(col) != "*") {
-                  var _column = $("<li>");
-                  _column.html("<a href='#' style='padding-left:10px'><i class='fa fa-columns'></i> " + col + "</a>");
-                  _column.appendTo(_table.find("ul"));
-                  _column.on("dblclick", function () {
-                    codeMirror.replaceSelection($.trim(col) + ', ');
-                    codeMirror.setSelection(codeMirror.getCursor());
-                    codeMirror.focus();
-                  });
-                }
+            }
+            else {
+              _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");
+              rdbms_getTableColumns(viewModel.server().name(), viewModel.database(), table, "", function (columns) {
+                _table.find("ul").empty();
+                _table.find(".fa-spinner").removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-table");
+                $(columns.split(" ")).each(function (iCnt, col) {
+                  if ($.trim(col) != "" && $.trim(col) != "*") {
+                    var _column = $("<li>");
+                    _column.html("<a href='#' style='padding-left:10px'><i class='fa fa-columns'></i> " + col + "</a>");
+                    _column.appendTo(_table.find("ul"));
+                    _column.on("dblclick", function () {
+                      codeMirror.replaceSelection($.trim(col) + ', ');
+                      codeMirror.setSelection(codeMirror.getCursor());
+                      codeMirror.focus();
+                    });
+                  }
+                });
               });
-            });
+            }
           });
           _table.find("a:eq(2)").on("dblclick", function () {
             codeMirror.replaceSelection($.trim(table) + ' ');