mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
take branch prefix into account while sorting, fixes #3896
This commit is contained in:
parent
fbffc6b2b5
commit
9b32d86f78
@ -61,6 +61,12 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE
|
|||||||
eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
|
eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
|
||||||
if (entityName === 'note_contents') { // FIXME
|
if (entityName === 'note_contents') { // FIXME
|
||||||
runAttachedRelations(entity, 'runOnNoteContentChange', entity);
|
runAttachedRelations(entity, 'runOnNoteContentChange', entity);
|
||||||
|
} else if (entityName === 'branches') {
|
||||||
|
const parentNote = becca.getNote(entity.parentNoteId);
|
||||||
|
|
||||||
|
if (parentNote?.hasLabel("sorted")) {
|
||||||
|
treeService.sortNotesIfNeeded(parentNote.noteId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -90,22 +90,29 @@ function sortNotes(parentNoteId, customSortBy = 'title', reverse = false, folder
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetchValue(note, key) {
|
function fetchValue(note, key) {
|
||||||
const rawValue = ['title', 'dateCreated', 'dateModified'].includes(key)
|
let rawValue;
|
||||||
? note[key]
|
|
||||||
: note.getLabelValue(key);
|
if (key === 'title') {
|
||||||
|
const branch = note.getParentBranches().find(branch => branch.parentNoteId === parentNoteId);
|
||||||
|
const prefix = branch?.prefix;
|
||||||
|
rawValue = prefix ? `${prefix} - ${note.title}` : note.title;
|
||||||
|
} else {
|
||||||
|
rawValue = ['dateCreated', 'dateModified'].includes(key)
|
||||||
|
? note[key]
|
||||||
|
: note.getLabelValue(key);
|
||||||
|
}
|
||||||
|
|
||||||
return normalize(rawValue);
|
return normalize(rawValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compare(a, b) {
|
function compare(a, b) {
|
||||||
if (!sortNatural){
|
if (!sortNatural) {
|
||||||
// alphabetical sort
|
// alphabetical sort
|
||||||
return b === null || b === undefined || a < b ? -1 : 1;
|
return b === null || b === undefined || a < b ? -1 : 1;
|
||||||
} else {
|
} else {
|
||||||
// natural sort
|
// natural sort
|
||||||
return a.localeCompare(b, sortLocale, {numeric: true, sensitivity: 'base'});
|
return a.localeCompare(b, sortLocale, {numeric: true, sensitivity: 'base'});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const topAEl = fetchValue(a, 'top');
|
const topAEl = fetchValue(a, 'top');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user