mirror of
https://github.com/zadam/trilium.git
synced 2024-12-27 09:43:18 +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):
|
class Tree(Resource):
|
||||||
def get(self):
|
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 = []
|
rootNotes = []
|
||||||
notesMap = {}
|
notesMap = {}
|
||||||
|
|
|
@ -28,8 +28,10 @@ function noteChanged() {
|
||||||
|
|
||||||
note.detail.note_title = title;
|
note.detail.note_title = title;
|
||||||
|
|
||||||
|
const note_id = note.detail.is_clone ? note.detail.note_clone_id : note.detail.note_id;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + 'notes/' + note.detail.note_id,
|
url: baseUrl + 'notes/' + note_id,
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: JSON.stringify(note),
|
data: JSON.stringify(note),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
|
|
|
@ -3,6 +3,11 @@ $(function(){
|
||||||
function copyTitle(notes) {
|
function copyTitle(notes) {
|
||||||
for (let note of notes) {
|
for (let note of notes) {
|
||||||
note.title = note.note_title;
|
note.title = note.note_title;
|
||||||
|
|
||||||
|
if (note.is_clone) {
|
||||||
|
note.title += " (clone)";
|
||||||
|
}
|
||||||
|
|
||||||
note.key = note.note_id;
|
note.key = note.note_id;
|
||||||
note.expanded = note.is_expanded;
|
note.expanded = note.is_expanded;
|
||||||
|
|
||||||
|
@ -31,8 +36,8 @@ $(function(){
|
||||||
extensions: ["hotkeys"],
|
extensions: ["hotkeys"],
|
||||||
source: notes,
|
source: notes,
|
||||||
activate: function(event, data){
|
activate: function(event, data){
|
||||||
var node = data.node.data;
|
const node = data.node.data;
|
||||||
var noteId = node.note_id;
|
const noteId = node.is_clone ? node.note_clone_id : node.note_id;
|
||||||
|
|
||||||
loadNote(noteId);
|
loadNote(noteId);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue