mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Merge remote-tracking branch 'origin/stable'
# Conflicts: # src/services/note_cache/entities/note.js
This commit is contained in:
commit
6408a47a8a
@ -1245,7 +1245,25 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
this.clearSelectedNodes();
|
||||
}
|
||||
|
||||
canBeMovedUpOrDown(node) {
|
||||
if (node.data.noteId === 'root') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parentNote = treeCache.getNoteFromCache(node.getParent().data.noteId);
|
||||
|
||||
if (parentNote && parentNote.hasLabel('sorted')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
moveNoteUpCommand({node}) {
|
||||
if (!this.canBeMovedUpOrDown(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const beforeNode = node.getPrevSibling();
|
||||
|
||||
if (beforeNode !== null) {
|
||||
@ -1254,7 +1272,12 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
}
|
||||
|
||||
moveNoteDownCommand({node}) {
|
||||
if (!this.canBeMovedUpOrDown(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const afterNode = node.getNextSibling();
|
||||
|
||||
if (afterNode !== null) {
|
||||
branchService.moveAfterBranch([node.data.branchId], afterNode.data.branchId);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ const scriptService = require('./script');
|
||||
const treeService = require('./tree');
|
||||
const noteService = require('./notes');
|
||||
const repository = require('./repository');
|
||||
const noteCache = require('./note_cache/note_cache');
|
||||
const Attribute = require('../entities/attribute');
|
||||
|
||||
function runAttachedRelations(note, relationName, originEntity) {
|
||||
@ -22,11 +23,11 @@ eventService.subscribe(eventService.NOTE_TITLE_CHANGED, note => {
|
||||
runAttachedRelations(note, 'runOnNoteTitleChange', note);
|
||||
|
||||
if (!note.isRoot()) {
|
||||
const parents = note.getParentNotes();
|
||||
const noteFromCache = noteCache.notes[note.noteId];
|
||||
|
||||
for (const parent of parents) {
|
||||
if (parent.hasOwnedLabel("sorted")) {
|
||||
treeService.sortNotesAlphabetically(parent.noteId);
|
||||
for (const parentNote of noteFromCache.parents) {
|
||||
if (parentNote.hasLabel("sorted")) {
|
||||
treeService.sortNotesAlphabetically(parentNote.noteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,6 +81,16 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
|
||||
}
|
||||
else if (entity.type === 'label' && entity.name === 'sorted') {
|
||||
treeService.sortNotesAlphabetically(entity.noteId);
|
||||
|
||||
if (entity.isInheritable) {
|
||||
const note = noteCache.notes[entity.noteId];
|
||||
|
||||
if (note) {
|
||||
for (const noteId of note.subtreeNoteIds) {
|
||||
treeService.sortNotesAlphabetically(noteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (entityName === 'notes') {
|
||||
|
@ -152,6 +152,14 @@ class Note {
|
||||
&& (!value || attr.value.toLowerCase() === value));
|
||||
}
|
||||
|
||||
hasLabel(name) {
|
||||
return this.hasAttribute('label', name);
|
||||
}
|
||||
|
||||
hasRelation(name) {
|
||||
return this.hasAttribute('relation', name);
|
||||
}
|
||||
|
||||
getLabelValue(name) {
|
||||
const label = this.attributes.find(attr => attr.type === 'label' && attr.name === name);
|
||||
|
||||
@ -294,6 +302,11 @@ class Note {
|
||||
return arr.flat();
|
||||
}
|
||||
|
||||
/** @return {String[]} */
|
||||
get subtreeNoteIds() {
|
||||
return this.subtreeNotes.map(note => note.noteId);
|
||||
}
|
||||
|
||||
get parentCount() {
|
||||
return this.parents.length;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user