mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
respect if note is supposed to be expanded or not and save expanded state
This commit is contained in:
parent
7bebf7ac5a
commit
20a1e71100
8
app.py
8
app.py
@ -211,6 +211,14 @@ class MoveToNote(Resource):
|
|||||||
|
|
||||||
api.add_resource(MoveToNote, '/notes/<string:note_id>/moveTo/<string:parent_id>')
|
api.add_resource(MoveToNote, '/notes/<string:note_id>/moveTo/<string:parent_id>')
|
||||||
|
|
||||||
|
class ExpandedNote(Resource):
|
||||||
|
def put(self, note_id, expanded):
|
||||||
|
execute("update notes_tree set is_expanded = ? where note_id = ?", [expanded, note_id])
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
api.add_resource(ExpandedNote, '/notes/<string:note_id>/expanded/<int:expanded>')
|
||||||
|
|
||||||
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.*, notes.note_title from notes_tree join notes on notes.note_id = notes_tree.note_id order by note_pid, note_pos")
|
||||||
|
2
frontend/.gitignore
vendored
2
frontend/.gitignore
vendored
@ -3,3 +3,5 @@ node_modules/
|
|||||||
dist/
|
dist/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
app.pyc
|
||||||
|
demo.ncdb
|
@ -235,6 +235,7 @@
|
|||||||
for (let note of notes) {
|
for (let note of notes) {
|
||||||
note.title = note.note_title;
|
note.title = note.note_title;
|
||||||
note.key = note.note_id;
|
note.key = note.note_id;
|
||||||
|
note.expanded = note.is_expanded;
|
||||||
|
|
||||||
if (note.children && note.children.length > 0) {
|
if (note.children && note.children.length > 0) {
|
||||||
copyTitle(note.children);
|
copyTitle(note.children);
|
||||||
@ -244,6 +245,19 @@
|
|||||||
|
|
||||||
copyTitle(notes);
|
copyTitle(notes);
|
||||||
|
|
||||||
|
function setExpanded(note_id, is_expanded) {
|
||||||
|
expanded_num = is_expanded ? 1 : 0;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + 'notes/' + note_id + '/expanded/' + expanded_num,
|
||||||
|
type: 'PUT',
|
||||||
|
contentType: "application/json",
|
||||||
|
success: function(result) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$("#tree").fancytree({
|
$("#tree").fancytree({
|
||||||
extensions: ["hotkeys"],
|
extensions: ["hotkeys"],
|
||||||
source: notes,
|
source: notes,
|
||||||
@ -253,6 +267,12 @@
|
|||||||
|
|
||||||
loadNote(noteId);
|
loadNote(noteId);
|
||||||
},
|
},
|
||||||
|
expand: function(event, data) {
|
||||||
|
setExpanded(data.node.key, true);
|
||||||
|
},
|
||||||
|
collapse: function(event, data) {
|
||||||
|
setExpanded(data.node.key, false);
|
||||||
|
},
|
||||||
hotkeys: {
|
hotkeys: {
|
||||||
keydown: {
|
keydown: {
|
||||||
"insert": function(node) {
|
"insert": function(node) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user