mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
correctly updating title for all clone nodes
This commit is contained in:
parent
4e0d83e9de
commit
16818e7583
@ -92,9 +92,9 @@ const noteEditor = (function() {
|
|||||||
|
|
||||||
const title = noteTitleEl.val();
|
const title = noteTitleEl.val();
|
||||||
|
|
||||||
noteTree.getCurrentNode().setTitle(title);
|
|
||||||
|
|
||||||
note.detail.note_title = title;
|
note.detail.note_title = title;
|
||||||
|
|
||||||
|
noteTree.setCurrentNoteTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveNoteToServer(note) {
|
async function saveNoteToServer(note) {
|
||||||
|
@ -73,6 +73,8 @@ const noteTree = (function() {
|
|||||||
|
|
||||||
noteIdToTitle[note.note_id] = note.note_title;
|
noteIdToTitle[note.note_id] = note.note_title;
|
||||||
|
|
||||||
|
delete note.note_title; // this should not be used. Use noteIdToTitle instead
|
||||||
|
|
||||||
const key = note.note_pid + "-" + note.note_id;
|
const key = note.note_pid + "-" + note.note_id;
|
||||||
|
|
||||||
parentChildToNoteTreeId[key] = note.note_tree_id;
|
parentChildToNoteTreeId[key] = note.note_tree_id;
|
||||||
@ -106,7 +108,7 @@ const noteTree = (function() {
|
|||||||
const noteTreeId = getNoteTreeId(parentNoteId, childNoteId);
|
const noteTreeId = getNoteTreeId(parentNoteId, childNoteId);
|
||||||
const note = notesMap[noteTreeId];
|
const note = notesMap[noteTreeId];
|
||||||
|
|
||||||
note.title = note.note_title;
|
note.title = noteIdToTitle[note.note_id];
|
||||||
|
|
||||||
note.extraClasses = "";
|
note.extraClasses = "";
|
||||||
|
|
||||||
@ -428,11 +430,15 @@ const noteTree = (function() {
|
|||||||
treeEl.contextmenu(contextMenu.contextMenuSettings);
|
treeEl.contextmenu(contextMenu.contextMenuSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTree() {
|
||||||
|
return treeEl.fancytree('getTree');
|
||||||
|
}
|
||||||
|
|
||||||
async function reload() {
|
async function reload() {
|
||||||
const notes = await loadTree();
|
const notes = await loadTree();
|
||||||
|
|
||||||
// this will also reload the note content
|
// this will also reload the note content
|
||||||
await treeEl.fancytree('getTree').reload(notes);
|
await getTree().reload(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTree() {
|
function loadTree() {
|
||||||
@ -488,7 +494,7 @@ const noteTree = (function() {
|
|||||||
function resetSearch() {
|
function resetSearch() {
|
||||||
$("input[name=search]").val("");
|
$("input[name=search]").val("");
|
||||||
|
|
||||||
const tree = treeEl.fancytree("getTree");
|
const tree = getTree();
|
||||||
tree.clearFilter();
|
tree.clearFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,6 +518,12 @@ const noteTree = (function() {
|
|||||||
return treeUtils.getNotePath(node);
|
return treeUtils.getNotePath(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentNoteId() {
|
||||||
|
const node = getCurrentNode();
|
||||||
|
|
||||||
|
return node ? node.data.note_id : null;
|
||||||
|
}
|
||||||
|
|
||||||
function setCurrentNoteTreeBasedOnProtectedStatus() {
|
function setCurrentNoteTreeBasedOnProtectedStatus() {
|
||||||
const node = getCurrentNode();
|
const node = getCurrentNode();
|
||||||
|
|
||||||
@ -556,6 +568,27 @@ const noteTree = (function() {
|
|||||||
return autocompleteItems;
|
return autocompleteItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentClones() {
|
||||||
|
const noteId = getCurrentNoteId();
|
||||||
|
|
||||||
|
if (noteId) {
|
||||||
|
return getTree().getNodesByRef(noteId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCurrentNoteTitle(title) {
|
||||||
|
const currentNoteId = getCurrentNoteId();
|
||||||
|
|
||||||
|
if (currentNoteId) {
|
||||||
|
noteIdToTitle[currentNoteId] = title;
|
||||||
|
|
||||||
|
getCurrentClones().map(clone => clone.setTitle(title));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$("button#reset-search-button").click(resetSearch);
|
$("button#reset-search-button").click(resetSearch);
|
||||||
|
|
||||||
$("input[name=search]").keyup(e => {
|
$("input[name=search]").keyup(e => {
|
||||||
@ -571,8 +604,7 @@ const noteTree = (function() {
|
|||||||
console.log("search: ", resp);
|
console.log("search: ", resp);
|
||||||
|
|
||||||
// Pass a string to perform case insensitive matching
|
// Pass a string to perform case insensitive matching
|
||||||
const tree = treeEl.fancytree("getTree");
|
getTree().filterBranches(node => {
|
||||||
tree.filterBranches(node => {
|
|
||||||
return resp.includes(node.data.note_id);
|
return resp.includes(node.data.note_id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -599,6 +631,7 @@ const noteTree = (function() {
|
|||||||
getCurrentNotePath,
|
getCurrentNotePath,
|
||||||
getNoteTitle,
|
getNoteTitle,
|
||||||
setCurrentNotePathToHash,
|
setCurrentNotePathToHash,
|
||||||
getAutocompleteItems
|
getAutocompleteItems,
|
||||||
|
setCurrentNoteTitle
|
||||||
};
|
};
|
||||||
})();
|
})();
|
Loading…
x
Reference in New Issue
Block a user