mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix branch prefix dialog
This commit is contained in:
parent
8d2c2202fa
commit
2fa41b44c5
@ -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.");
|
||||
|
@ -52,11 +52,12 @@ export default class DialogEventComponent extends Component {
|
||||
}
|
||||
|
||||
async editBranchPrefixListener() {
|
||||
// FIXME
|
||||
const node = this.appContext.getMainNoteTree().getActiveNode();
|
||||
const notePath = this.appContext.tabManager.getActiveTabNotePath();
|
||||
|
||||
const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");
|
||||
editBranchPrefixDialog.showDialog(node);
|
||||
if (notePath) {
|
||||
const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");
|
||||
editBranchPrefixDialog.showDialog(notePath);
|
||||
}
|
||||
}
|
||||
|
||||
addLinkToTextListener() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user