Pārlūkot izejas kodu

HUE-5367 [editor] Editor resets vertical scrolling after query is executed

Enrico Berti 9 gadi atpakaļ
vecāks
revīzija
e830925a9a

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/jquery.huedatatable.js

@@ -444,7 +444,6 @@
           })
         })
       }
-
       self.fnDraw(true);
 
       if ($('.hue-datatable-search').is(':visible')){
@@ -478,6 +477,7 @@
       self.$table.unwrap();
       self.$table.data('isScrollAttached', null);
       self.$table.removeClass('table-huedatatable');
+      self.$table.parents(self.$table.data('oInit')['scrollable']).off('scroll', self.$table.parents(self.$table.data('oInit')['scrollable']).data('scrollFnDt'));
     };
 
     return self.each(function () {

+ 1 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -920,7 +920,7 @@ var EditorViewModel = (function() {
         chartScatterGroup: typeof self.chartScatterGroup() !== "undefined" ? self.chartScatterGroup() : self.previousChartOptions.chartScatterGroup,
         chartScatterSize: typeof self.chartScatterSize() !== "undefined" ? self.chartScatterSize() : self.previousChartOptions.chartScatterSize
       };
-      $(document).trigger("executeStarted", self);
+      $(document).trigger("executeStarted", {vm: vm, snippet: self});
       self.lastExecuted(now);
       $(".jHueNotify").hide();
       logGA('execute/' + self.type());

+ 20 - 15
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -2554,6 +2554,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       },
       fnDrawCallback: function (oSettings) {
         if (vm.editorMode()) {
+          $('#queryResults').removeAttr('style');
           DATATABLES_MAX_HEIGHT = $(window).height() - $(el).parent().offset().top - 40;
           $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
           $(el).jHueHorizontalScrollbar();
@@ -3850,24 +3851,28 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         window.setTimeout(forceChartDraws, 50);
       });
 
-      $(document).on("executeStarted", function (e, snippet) {
-        var _el = $("#snippet_" + snippet.id()).find(".resultTable");
-        _el.data('scrollToCol', null);
-        _el.data('scrollToRow', null);
-        $("#snippet_" + snippet.id()).find(".progress-snippet").animate({
+      $(document).on("executeStarted", function (e, options) {
+        var $el = $("#snippet_" + options.snippet.id()).find(".resultTable");
+        if (options.vm.editorMode()) {
+          $('#queryResults').css({
+            height: $el.height() + 'px'
+          });
+        }
+        $el.data('scrollToCol', null);
+        $el.data('scrollToRow', null);
+        $("#snippet_" + options.snippet.id()).find(".progress-snippet").animate({
           height: "3px"
         }, 100);
-        if (_el.hasClass("dt")) {
-          _el.removeClass("dt");
-          $("#eT" + snippet.id() + "jHueTableExtenderClonedContainer").remove();
-          $("#eT" + snippet.id() + "jHueTableExtenderClonedContainerColumn").remove();
-          $("#eT" + snippet.id() + "jHueTableExtenderClonedContainerCell").remove();
-          if (_el.hueDataTable()) {
-            _el.hueDataTable().fnClearTable();
-            _el.hueDataTable().fnDestroy();
+        if ($el.hasClass("dt")) {
+          $el.removeClass("dt");
+          $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainer").remove();
+          $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainerColumn").remove();
+          $("#eT" + options.snippet.id() + "jHueTableExtenderClonedContainerCell").remove();
+          if ($el.hueDataTable()) {
+            $el.hueDataTable().fnDestroy();
           }
-          _el.find("thead tr").empty();
-          _el.data('lockedRows', {});
+          $el.find("thead tr").empty();
+          $el.data('lockedRows', {});
         }
       });