Repository: zeppelin
Updated Branches:
  refs/heads/master ee51a84e8 -> 076a2aae9


[ZEPPELIN-1113] Don't save Paragraph ColWidth if not necessary

### What is this PR for?
We currently are saving the ColWidth changes all the time, while it is not 
necessary if the value is the same.

### What type of PR is it?
Improvement

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1113

### How should this be tested?
* Select a Col-12 Paragraph and use the shortcut Ctr+Shift+ = to make it bigger
* You shouldn't see any `Send >> "COMMIT_PARAGRAPH"` in your browser console

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Damien CORNEAU <[email protected]>

Closes #1130 from corneadoug/fix/dontSendSimilarColWidth and squashes the 
following commits:

276ed64 [Damien CORNEAU] Fix dropdown changeColWidth
ddbb04a [Damien CORNEAU] Fix setting change width
7d471c0 [Damien CORNEAU] Add parameter to changeColWidth and check value


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/076a2aae
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/076a2aae
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/076a2aae

Branch: refs/heads/master
Commit: 076a2aae98626a4d6f4943a9615a620a73298a78
Parents: ee51a84
Author: Damien CORNEAU <[email protected]>
Authored: Wed Jul 6 12:27:22 2016 +0900
Committer: Anthony Corbacho <[email protected]>
Committed: Thu Jul 7 17:28:16 2016 +0900

----------------------------------------------------------------------
 .../notebook/paragraph/paragraph.controller.js  | 34 +++++++++-----------
 1 file changed, 15 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/076a2aae/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js 
b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index dd0ad7d..7ed029d 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -698,12 +698,17 @@ angular.module('zeppelinWebApp')
     }
   };
 
-  $scope.changeColWidth = function() {
+  $scope.changeColWidth = function(width) {
     angular.element('.navbar-right.open').removeClass('open');
-    var newParams = angular.copy($scope.paragraph.settings.params);
-    var newConfig = angular.copy($scope.paragraph.config);
+    if (!width || width !== $scope.paragraph.config.colWidth) {
+      if (width) {
+        $scope.paragraph.config.colWidth = width;
+      }
+      var newParams = angular.copy($scope.paragraph.settings.params);
+      var newConfig = angular.copy($scope.paragraph.config);
 
-    commitParagraph($scope.paragraph.title, $scope.paragraph.text, newConfig, 
newParams);
+      commitParagraph($scope.paragraph.title, $scope.paragraph.text, 
newConfig, newParams);
+    }
   };
 
   $scope.toggleGraphOption = function() {
@@ -1107,11 +1112,9 @@ angular.module('zeppelinWebApp')
           $scope.showLineNumbers();
         }
       } else if (keyEvent.ctrlKey && keyEvent.shiftKey && keyCode === 189) { 
// Ctrl + Shift + -
-        $scope.paragraph.config.colWidth = Math.max(1, 
$scope.paragraph.config.colWidth - 1);
-        $scope.changeColWidth();
+        $scope.changeColWidth(Math.max(1, $scope.paragraph.config.colWidth - 
1));
       } else if (keyEvent.ctrlKey && keyEvent.shiftKey && keyCode === 187) { 
// Ctrl + Shift + =
-        $scope.paragraph.config.colWidth = Math.min(12, 
$scope.paragraph.config.colWidth + 1);
-        $scope.changeColWidth();
+        $scope.changeColWidth(Math.min(12, $scope.paragraph.config.colWidth + 
1));
       } else if (keyEvent.ctrlKey && keyEvent.altKey && keyCode === 84) { // 
Ctrl + Alt + t
         if ($scope.paragraph.config.title) {
           $scope.hideTitle();
@@ -2152,18 +2155,11 @@ angular.module('zeppelinWebApp')
   };
 
   $scope.resizeParagraph = function(width, height) {
-    if ($scope.paragraph.config.colWidth !== width) {
-
-        $scope.paragraph.config.colWidth = width;
-        $scope.changeColWidth();
-        $timeout(function() {
-          autoAdjustEditorHeight($scope.paragraph.id + '_editor');
-          $scope.changeHeight(height);
-        }, 200);
-
-    } else {
+    $scope.changeColWidth(width);
+    $timeout(function() {
+      autoAdjustEditorHeight($scope.paragraph.id + '_editor');
       $scope.changeHeight(height);
-    }
+    }, 200);
   };
 
   $scope.changeHeight = function(height) {

Reply via email to