mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	add support for the persistent #sortDirection and #sortFoldersFirst (one time UI action exists), closes #3046
This commit is contained in:
		
							
								
								
									
										1
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -5,6 +5,7 @@ | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "trilium", | ||||
|       "version": "0.54.1-beta", | ||||
|       "hasInstallScript": true, | ||||
|       "license": "AGPL-3.0-only", | ||||
|   | ||||
| @@ -135,10 +135,6 @@ function getSomeNotePath(note, hoistedNotePath = 'root') { | ||||
|     return notePath === null ? null : notePath.join('/'); | ||||
| } | ||||
|  | ||||
| async function sortAlphabetically(noteId) { | ||||
|     await server.put(`notes/${noteId}/sort`); | ||||
| } | ||||
|  | ||||
| ws.subscribeToMessages(message => { | ||||
|    if (message.type === 'openNote') { | ||||
|        appContext.tabManager.activateOrOpenNote(message.noteId); | ||||
| @@ -319,7 +315,6 @@ function parseNotePath(notePath) { | ||||
| } | ||||
|  | ||||
| export default { | ||||
|     sortAlphabetically, | ||||
|     resolveNotePath, | ||||
|     resolveNotePathToSegments, | ||||
|     getSomeNotePath, | ||||
|   | ||||
| @@ -189,6 +189,8 @@ const ATTR_HELP = { | ||||
|         "runAtHour": "On which hour should this run. Should be used together with <code>#run=hourly</code>. Can be defined multiple times for more runs during the day.", | ||||
|         "disableInclusion": "scripts with this label won't be included into parent script execution.", | ||||
|         "sorted": "keeps child notes sorted by title alphabetically", | ||||
|         "sortDirection": "ASC (the default) or DESC", | ||||
|         "sortFoldersFirst": "Folders (notes with children) should be sorted on top", | ||||
|         "top": "keep given note on top in its parent (applies only on sorted parents)", | ||||
|         "hidePromotedAttributes": "Hide promoted attributes on this note", | ||||
|         "readOnly": "editor is in read only mode. Works only for text and code notes.", | ||||
|   | ||||
| @@ -41,6 +41,8 @@ module.exports = [ | ||||
|     { type: 'label', name: 'bookmarked' }, | ||||
|     { type: 'label', name: 'bookmarkFolder' }, | ||||
|     { type: 'label', name: 'sorted' }, | ||||
|     { type: 'label', name: 'sortDirection' }, | ||||
|     { type: 'label', name: 'sortFoldersFirst' }, | ||||
|     { type: 'label', name: 'top' }, | ||||
|     { type: 'label', name: 'fullContentWidth' }, | ||||
|     { type: 'label', name: 'shareHiddenFromTree' }, | ||||
|   | ||||
| @@ -46,7 +46,7 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE | ||||
|     if (entityName === 'attributes') { | ||||
|         runAttachedRelations(entity.getNote(), 'runOnAttributeChange', entity); | ||||
|  | ||||
|         if (entity.type === 'label' && entity.name === 'sorted') { | ||||
|         if (entity.type === 'label' && ['sorted', 'sortDirection', 'sortFoldersFirst'].includes(entity.name)) { | ||||
|             handleSortedAttribute(entity); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -204,7 +204,11 @@ function sortNotesIfNeeded(parentNoteId) { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     sortNotes(parentNoteId, sortedLabel.value); | ||||
|     const sortReversed = parentNote.getLabelValue('sortDirection')?.toLowerCase() === "desc"; | ||||
|     const sortFoldersFirstLabel = parentNote.getLabel('sortFoldersFirst'); | ||||
|     const sortFoldersFirst = sortFoldersFirstLabel && sortFoldersFirstLabel.value.toLowerCase() !== "false"; | ||||
|  | ||||
|     sortNotes(parentNoteId, sortedLabel.value, sortReversed, sortFoldersFirst); | ||||
| } | ||||
|  | ||||
| /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user