mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	added "hoistedInbox" label
This commit is contained in:
		| @@ -196,7 +196,16 @@ const ATTR_HELP = { | |||||||
|         "iconClass": "value of this label is added as a CSS class to the icon on the tree which can help visually distinguish the notes in the tree. Example might be bx bx-home - icons are taken from boxicons. Can be used in template notes.", |         "iconClass": "value of this label is added as a CSS class to the icon on the tree which can help visually distinguish the notes in the tree. Example might be bx bx-home - icons are taken from boxicons. Can be used in template notes.", | ||||||
|         "pageSize": "number of items per page in note listing", |         "pageSize": "number of items per page in note listing", | ||||||
|         "customRequestHandler": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>', |         "customRequestHandler": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>', | ||||||
|         "customResourceProvider": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>' |         "customResourceProvider": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>', | ||||||
|  |         "widget": "marks this note as a custom widget which will be added to the Trilium component tree", | ||||||
|  |         "workspace": "marks this note as a workspace which allows easy hoisting", | ||||||
|  |         "workspaceIconClass": "defines box icon CSS class which will be used in tab when hoisted to this note", | ||||||
|  |         "workspaceTabBackgroundColor": "CSS color used in the note tab when hoisted to this note", | ||||||
|  |         "searchHome": "new search notes will be created as children of this note", | ||||||
|  |         "hoistedSearchHome": "new search notes will be created as children of this note when hoisted to some ancestor of this note", | ||||||
|  |         "inbox": "default inbox location for new notes", | ||||||
|  |         "hoistedInbox": "default inbox location for new notes when hoisted to some ancestor of this note", | ||||||
|  |         "sqlConsoleHome": "default location of SQL console notes", | ||||||
|     }, |     }, | ||||||
|     "relation": { |     "relation": { | ||||||
|         "runOnNoteCreation": "executes when note is created on backend", |         "runOnNoteCreation": "executes when note is created on backend", | ||||||
|   | |||||||
| @@ -9,10 +9,29 @@ const cls = require('../../services/cls'); | |||||||
| const repository = require('../../services/repository'); | const repository = require('../../services/repository'); | ||||||
|  |  | ||||||
| function getInboxNote(req) { | function getInboxNote(req) { | ||||||
|     return attributeService.getNoteWithLabel('inbox') |     const hoistedNote = getHoistedNote(); | ||||||
|  |  | ||||||
|  |     let inbox; | ||||||
|  |  | ||||||
|  |     if (hoistedNote) { | ||||||
|  |         ([inbox] = hoistedNote.getDescendantNotesWithLabel('hoistedInbox')); | ||||||
|  |  | ||||||
|  |         if (!inbox) { | ||||||
|  |             ([inbox] = hoistedNote.getDescendantNotesWithLabel('inbox')); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (!inbox) { | ||||||
|  |             inbox = hoistedNote; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         inbox = attributeService.getNoteWithLabel('inbox') | ||||||
|             || dateNoteService.getDateNote(req.params.date); |             || dateNoteService.getDateNote(req.params.date); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     return inbox; | ||||||
|  | } | ||||||
|  |  | ||||||
| function getDateNote(req) { | function getDateNote(req) { | ||||||
|     return dateNoteService.getDateNote(req.params.date); |     return dateNoteService.getDateNote(req.params.date); | ||||||
| } | } | ||||||
| @@ -66,27 +85,18 @@ function createSearchNote(req) { | |||||||
|     const searchString = params.searchString || ""; |     const searchString = params.searchString || ""; | ||||||
|     let ancestorNoteId = params.ancestorNoteId; |     let ancestorNoteId = params.ancestorNoteId; | ||||||
|  |  | ||||||
|     const hoistedNote = cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root' |     const hoistedNote = getHoistedNote(); | ||||||
|         ? repository.getNote(cls.getHoistedNoteId()) |  | ||||||
|         : null; |  | ||||||
|  |  | ||||||
|     let searchHome; |     let searchHome; | ||||||
|  |  | ||||||
|     if (hoistedNote) { |     if (hoistedNote) { | ||||||
|         ([searchHome] = hoistedNote.getDescendantNotesWithLabel('hoistedSearchHome')); |         ([searchHome] = hoistedNote.getDescendantNotesWithLabel('hoistedSearchHome')); | ||||||
|  |  | ||||||
|  |         if (!searchHome) { | ||||||
|  |             ([searchHome] = hoistedNote.getDescendantNotesWithLabel('searchHome')); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!searchHome) { |         if (!searchHome) { | ||||||
|         const today = dateUtils.localNowDate(); |  | ||||||
|  |  | ||||||
|         searchHome = attributeService.getNoteWithLabel('searchHome') |  | ||||||
|                   || dateNoteService.getDateNote(today); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (hoistedNote) { |  | ||||||
|  |  | ||||||
|         if (!hoistedNote.getDescendantNoteIds().includes(searchHome.noteId)) { |  | ||||||
|             // otherwise the note would be saved outside of the hoisted context which is weird |  | ||||||
|             searchHome = hoistedNote; |             searchHome = hoistedNote; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -94,6 +104,12 @@ function createSearchNote(req) { | |||||||
|             ancestorNoteId = hoistedNote.noteId; |             ancestorNoteId = hoistedNote.noteId; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     else { | ||||||
|  |         const today = dateUtils.localNowDate(); | ||||||
|  |  | ||||||
|  |         searchHome = attributeService.getNoteWithLabel('searchHome') | ||||||
|  |                   || dateNoteService.getDateNote(today); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     const {note} = noteService.createNewNote({ |     const {note} = noteService.createNewNote({ | ||||||
|         parentNoteId: searchHome.noteId, |         parentNoteId: searchHome.noteId, | ||||||
| @@ -112,6 +128,12 @@ function createSearchNote(req) { | |||||||
|     return note; |     return note; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function getHoistedNote() { | ||||||
|  |     return cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root' | ||||||
|  |         ? repository.getNote(cls.getHoistedNoteId()) | ||||||
|  |         : null; | ||||||
|  | } | ||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|     getInboxNote, |     getInboxNote, | ||||||
|     getDateNote, |     getDateNote, | ||||||
|   | |||||||
| @@ -37,6 +37,7 @@ const BUILTIN_ATTRIBUTES = [ | |||||||
|     { type: 'label', name: 'workspaceIconClass' }, |     { type: 'label', name: 'workspaceIconClass' }, | ||||||
|     { type: 'label', name: 'workspaceTabBackgroundColor' }, |     { type: 'label', name: 'workspaceTabBackgroundColor' }, | ||||||
|     { type: 'label', name: 'searchHome' }, |     { type: 'label', name: 'searchHome' }, | ||||||
|  |     { type: 'label', name: 'hoistedInbox' }, | ||||||
|     { type: 'label', name: 'hoistedSearchHome' }, |     { type: 'label', name: 'hoistedSearchHome' }, | ||||||
|     { type: 'label', name: 'sqlConsoleHome' }, |     { type: 'label', name: 'sqlConsoleHome' }, | ||||||
|     { type: 'label', name: 'datePattern' }, |     { type: 'label', name: 'datePattern' }, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user