Browse Source

HUE-8155 [metastore] Only show the edit description icon when the description is expanded

Johan Ahlen 7 years ago
parent
commit
7a7592743e

+ 10 - 8
desktop/core/src/desktop/static/desktop/js/ko.editable.js

@@ -91,15 +91,17 @@
       var onActionRender = undefined;
       var onActionRender = undefined;
 
 
       if (editableOptions.inlineEditAction) {
       if (editableOptions.inlineEditAction) {
-        onActionRender = function ($container) {
-          var $editAction = $('<a href="javascript:void(0);"><i class="fa fa-fw fa-pencil"></i></a>');
-          if (editableOptions.inlineEditAction.editClass) {
-            $editAction.addClass(editableOptions.inlineEditAction.editClass);
+        onActionRender = function ($container, overflowing) {
+          if (!overflowing) {
+            var $editAction = $('<a href="javascript:void(0);"><i class="fa fa-fw fa-pencil"></i></a>');
+            if (editableOptions.inlineEditAction.editClass) {
+              $editAction.addClass(editableOptions.inlineEditAction.editClass);
+            }
+            $editAction.on('click', function () {
+              $editable.editable('toggle');
+            });
+            $editAction.appendTo($container);
           }
           }
-          $editAction.on('click', function () {
-            $editable.editable('toggle');
-          });
-          $editAction.appendTo($container);
         }
         }
       }
       }
 
 

+ 7 - 3
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -624,13 +624,17 @@
       self.pause();
       self.pause();
     };
     };
 
 
+    var checkOverflow = function (element) {
+      return element.offsetHeight < element.scrollHeight || element.offsetWidth < element.scrollWidth
+    };
+
     MultiLineEllipsisHandler.prototype.refresh = function () {
     MultiLineEllipsisHandler.prototype.refresh = function () {
       var self = this;
       var self = this;
       self.$element.empty();
       self.$element.empty();
       var textElement = $('<span>').appendTo(self.$element)[0];
       var textElement = $('<span>').appendTo(self.$element)[0];
       if (self.expandable) {
       if (self.expandable) {
         textElement.innerHTML = self.renderContents ? self.renderContents(self.contents) : self.contents;
         textElement.innerHTML = self.renderContents ? self.renderContents(self.contents) : self.contents;
-        if (self.expanded || self.element.offsetHeight < self.element.scrollHeight || self.element.offsetWidth < self.element.scrollWidth) {
+        if (self.expanded || checkOverflow(self.element)) {
           self.$element.append('&nbsp;');
           self.$element.append('&nbsp;');
           var $expandLink = $('<a href="javascript:void(0);"><i class="fa fa-fw ' + (self.expanded ? 'fa-angle-double-up' : 'fa-angle-double-down') + '"></i></a>');
           var $expandLink = $('<a href="javascript:void(0);"><i class="fa fa-fw ' + (self.expanded ? 'fa-angle-double-up' : 'fa-angle-double-down') + '"></i></a>');
           if (self.expandClass) {
           if (self.expandClass) {
@@ -653,12 +657,12 @@
       }
       }
 
 
       if (self.onActionRender) {
       if (self.onActionRender) {
-        self.onActionRender(self.$element);
+        self.onActionRender(self.$element, checkOverflow(self.element));
       }
       }
 
 
       self.isOverflowing = false;
       self.isOverflowing = false;
 
 
-      while (self.element.offsetHeight < self.element.scrollHeight || self.element.offsetWidth < self.element.scrollWidth) {
+      while (checkOverflow(self.element)) {
         self.isOverflowing = true;
         self.isOverflowing = true;
         var contents = $(textElement).contents();
         var contents = $(textElement).contents();
         var lastContent = contents[contents.length - 1];
         var lastContent = contents[contents.length - 1];