Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions zeppelin-web/src/app/notebook/notebook.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 13 additions & 6 deletions zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down Expand Up @@ -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 === true) {
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
Expand Down