From 19e747999146af56b803696561001977d786032d Mon Sep 17 00:00:00 2001 From: CloverHearts Date: Wed, 26 Apr 2017 17:30:43 +0900 Subject: [PATCH 1/2] block update paragraph event on revision mode --- .../paragraph/paragraph.controller.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index 1a921769f49..abde97725f7 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -610,7 +610,9 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca let session = editor.getSession() let dirtyText = session.getValue() $scope.dirtyText = dirtyText - $scope.startSaveTimer() + if ($scope.dirtyText != $scope.originalText) { + $scope.startSaveTimer(); + } setParagraphMode(session, dirtyText, editor.getCursorPosition()) } @@ -1241,23 +1243,28 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca } $scope.updateParagraph = function (oldPara, newPara, updateCallback) { - // 1. get status, refreshed + // 1. can't update on revision view + if (!!$scope.revisionView) { + return; + } + + // 2. get status, refreshed const statusChanged = (newPara.status !== oldPara.status) const resultRefreshed = (newPara.dateFinished !== oldPara.dateFinished) || isEmpty(newPara.results) !== isEmpty(oldPara.results) || newPara.status === ParagraphStatus.ERROR || (newPara.status === ParagraphStatus.FINISHED && statusChanged) - // 2. update texts managed by $scope + // 3. update texts managed by $scope $scope.updateAllScopeTexts(oldPara, newPara) - // 3. execute callback to update result + // 4. execute callback to update result updateCallback() - // 4. update remaining paragraph objects + // 5. update remaining paragraph objects $scope.updateParagraphObjectWhenUpdated(newPara) - // 5. handle scroll down by key properly if new paragraph is added + // 6. handle scroll down by key properly if new paragraph is added if (statusChanged || resultRefreshed) { // when last paragraph runs, zeppelin automatically appends new paragraph. // this broadcast will focus to the newly inserted paragraph From 8fe72c9cf017b26e4235f3c273ceb5dd2d8dfb3a Mon Sep 17 00:00:00 2001 From: CloverHearts Date: Fri, 28 Apr 2017 14:02:48 +0900 Subject: [PATCH 2/2] add block event on revision mode --- zeppelin-web/src/app/notebook/notebook.controller.js | 10 ++++++++-- .../src/app/notebook/paragraph/paragraph.controller.js | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index e481e9be4cd..4b02f1a979d 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -483,20 +483,23 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, } $scope.$on('addParagraph', function (event, paragraph, index) { - if ($scope.paragraphUrl) { + if ($scope.paragraphUrl || $scope.revisionView === true) { return } addPara(paragraph, index) }) $scope.$on('removeParagraph', function (event, paragraphId) { - if ($scope.paragraphUrl) { + if ($scope.paragraphUrl || $scope.revisionView === true) { return } removePara(paragraphId) }) $scope.$on('moveParagraph', function (event, paragraphId, newIdx) { + if ($scope.revisionView === true) { + return + } let removedPara = removePara(paragraphId) if (removedPara && removedPara.length === 1) { addPara(removedPara[0], newIdx) @@ -958,6 +961,9 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, }) $scope.$on('insertParagraph', function (event, paragraphId, position) { + if ($scope.revisionView === true) { + return + } let newIndex = -1 for (let i = 0; i < $scope.note.paragraphs.length; i++) { if ($scope.note.paragraphs[i].id === paragraphId) { diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index abde97725f7..ae28e457ba5 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -610,8 +610,8 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca let session = editor.getSession() let dirtyText = session.getValue() $scope.dirtyText = dirtyText - if ($scope.dirtyText != $scope.originalText) { - $scope.startSaveTimer(); + if ($scope.dirtyText !== $scope.originalText) { + $scope.startSaveTimer() } setParagraphMode(session, dirtyText, editor.getCursorPosition()) } @@ -1244,8 +1244,8 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca $scope.updateParagraph = function (oldPara, newPara, updateCallback) { // 1. can't update on revision view - if (!!$scope.revisionView) { - return; + if ($scope.revisionView === true) { + return } // 2. get status, refreshed