mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
ZEPPELIN-2922 Allow removing last paragraph
This commit is contained in:
parent
b14f5ab956
commit
73fd0659ad
4 changed files with 11 additions and 11 deletions
|
|
@ -1297,9 +1297,10 @@ public class NotebookServer extends WebSocketServlet
|
|||
return;
|
||||
}
|
||||
|
||||
/** We dont want to remove the last paragraph */
|
||||
final Note note = notebook.getNote(noteId);
|
||||
if (!note.isLastParagraph(paragraphId)) {
|
||||
|
||||
/** Don't allow removing paragraph when there is only one paragraph in the Notebook */
|
||||
if (note.getParagraphCount() > 1) {
|
||||
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
|
||||
Paragraph para = note.removeParagraph(subject.getUser(), paragraphId);
|
||||
note.persist(subject);
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ limitations under the License.
|
|||
</li>
|
||||
<li>
|
||||
<!-- remove paragraph -->
|
||||
<a ng-click="removeParagraph(paragraph)" ng-hide="$last"><span class="fa fa-times shortcut-icon"></span>
|
||||
<a ng-click="removeParagraph(paragraph)" ng-if="note.paragraphs.length > 1"><span class="fa fa-times shortcut-icon"></span>
|
||||
<span class="shortcut-keys">Ctrl+{{ isMac ? 'Option' : 'Alt'}}+D</span>
|
||||
Remove
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -516,18 +516,13 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca
|
|||
}
|
||||
|
||||
$scope.removeParagraph = function (paragraph) {
|
||||
let paragraphs = angular.element('div[id$="_paragraphColumn_main"]')
|
||||
if (paragraphs[paragraphs.length - 1].id.indexOf(paragraph.id) === 0) {
|
||||
if ($scope.note.paragraphs.length === 1) {
|
||||
BootstrapDialog.alert({
|
||||
closable: true,
|
||||
message: 'The last paragraph can\'t be deleted.',
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
$scope.editor.focus()
|
||||
}
|
||||
}
|
||||
message: 'All the paragraphs can\'t be deleted.'
|
||||
})
|
||||
} else {
|
||||
let paragraphs = angular.element('div[id$="_paragraphColumn_main"]')
|
||||
BootstrapDialog.confirm({
|
||||
closable: true,
|
||||
title: '',
|
||||
|
|
|
|||
|
|
@ -507,6 +507,10 @@ public class Note implements ParagraphJobListener, JsonSerializable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public int getParagraphCount() {
|
||||
return paragraphs.size();
|
||||
}
|
||||
|
||||
public Paragraph getParagraph(String paragraphId) {
|
||||
synchronized (paragraphs) {
|
||||
for (Paragraph p : paragraphs) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue