mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 09:12:08 +08:00
support for cloned notes including updating clones. Creating clones is not supported. Renaming is handled a bit differently - all clones and original share the same name, while in Notecase desktop each clone has separate name.
This commit is contained in:
parent
3c924afbca
commit
b986e93356
3 changed files with 19 additions and 4 deletions
10
src/tree.py
10
src/tree.py
|
@ -7,7 +7,15 @@ from sql import getResults
|
|||
|
||||
class Tree(Resource):
|
||||
def get(self):
|
||||
notes = getResults("select notes_tree.*, notes.note_title from notes_tree join notes on notes.note_id = notes_tree.note_id order by note_pid, note_pos")
|
||||
notes = getResults("select "
|
||||
"notes_tree.*, "
|
||||
"COALESCE(clone.note_title, notes.note_title) as note_title, "
|
||||
"notes.note_clone_id, "
|
||||
"case when notes.note_clone_id is null or notes.note_clone_id = '' then 0 else 1 end as is_clone "
|
||||
"from notes_tree "
|
||||
"join notes on notes.note_id = notes_tree.note_id "
|
||||
"left join notes as clone on notes.note_clone_id = clone.note_id "
|
||||
"order by note_pid, note_pos")
|
||||
|
||||
rootNotes = []
|
||||
notesMap = {}
|
||||
|
|
|
@ -28,8 +28,10 @@ function noteChanged() {
|
|||
|
||||
note.detail.note_title = title;
|
||||
|
||||
const note_id = note.detail.is_clone ? note.detail.note_clone_id : note.detail.note_id;
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + 'notes/' + note.detail.note_id,
|
||||
url: baseUrl + 'notes/' + note_id,
|
||||
type: 'PUT',
|
||||
data: JSON.stringify(note),
|
||||
contentType: "application/json",
|
||||
|
|
|
@ -3,6 +3,11 @@ $(function(){
|
|||
function copyTitle(notes) {
|
||||
for (let note of notes) {
|
||||
note.title = note.note_title;
|
||||
|
||||
if (note.is_clone) {
|
||||
note.title += " (clone)";
|
||||
}
|
||||
|
||||
note.key = note.note_id;
|
||||
note.expanded = note.is_expanded;
|
||||
|
||||
|
@ -31,8 +36,8 @@ $(function(){
|
|||
extensions: ["hotkeys"],
|
||||
source: notes,
|
||||
activate: function(event, data){
|
||||
var node = data.node.data;
|
||||
var noteId = node.note_id;
|
||||
const node = data.node.data;
|
||||
const noteId = node.is_clone ? node.note_clone_id : node.note_id;
|
||||
|
||||
loadNote(noteId);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue