fix branch prefix dialog

This commit is contained in:
zadam
2020-02-14 21:21:47 +01:00
parent 8d2c2202fa
commit 2fa41b44c5
2 changed files with 15 additions and 10 deletions

View File

@@ -11,11 +11,17 @@ const $noteTitle = $('#branch-prefix-note-title');
let branchId;
export async function showDialog(node) {
branchId = node.data.branchId;
export async function showDialog(notePath) {
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
if (!noteId || !parentNoteId) {
return;
}
branchId = await treeCache.getBranchId(parentNoteId, noteId);
const branch = treeCache.getBranch(branchId);
if (branch.noteId === 'root') {
if (!branch || branch.noteId === 'root') {
return;
}
@@ -29,7 +35,7 @@ export async function showDialog(node) {
$treePrefixInput.val(branch.prefix);
const noteTitle = await treeService.getNoteTitle(node.data.noteId);
const noteTitle = await treeService.getNoteTitle(noteId);
$noteTitle.text(" - " + noteTitle);
}
@@ -39,8 +45,6 @@ async function savePrefix() {
await server.put('branches/' + branchId + '/set-prefix', { prefix: prefix });
await treeService.setPrefix(branchId, prefix);
$dialog.modal('hide');
toastService.showMessage("Branch prefix has been saved.");