mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added "hoistedInbox" label
This commit is contained in:
parent
584fea1992
commit
98f02c3c9a
@ -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.",
|
||||
"pageSize": "number of items per page in note listing",
|
||||
"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": {
|
||||
"runOnNoteCreation": "executes when note is created on backend",
|
||||
|
@ -9,8 +9,27 @@ const cls = require('../../services/cls');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
function getInboxNote(req) {
|
||||
return attributeService.getNoteWithLabel('inbox')
|
||||
|| dateNoteService.getDateNote(req.params.date);
|
||||
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);
|
||||
}
|
||||
|
||||
return inbox;
|
||||
}
|
||||
|
||||
function getDateNote(req) {
|
||||
@ -66,27 +85,18 @@ function createSearchNote(req) {
|
||||
const searchString = params.searchString || "";
|
||||
let ancestorNoteId = params.ancestorNoteId;
|
||||
|
||||
const hoistedNote = cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root'
|
||||
? repository.getNote(cls.getHoistedNoteId())
|
||||
: null;
|
||||
const hoistedNote = getHoistedNote();
|
||||
|
||||
let searchHome;
|
||||
|
||||
if (hoistedNote) {
|
||||
([searchHome] = hoistedNote.getDescendantNotesWithLabel('hoistedSearchHome'));
|
||||
}
|
||||
|
||||
if (!searchHome) {
|
||||
const today = dateUtils.localNowDate();
|
||||
if (!searchHome) {
|
||||
([searchHome] = hoistedNote.getDescendantNotesWithLabel('searchHome'));
|
||||
}
|
||||
|
||||
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
|
||||
if (!searchHome) {
|
||||
searchHome = hoistedNote;
|
||||
}
|
||||
|
||||
@ -94,6 +104,12 @@ function createSearchNote(req) {
|
||||
ancestorNoteId = hoistedNote.noteId;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const today = dateUtils.localNowDate();
|
||||
|
||||
searchHome = attributeService.getNoteWithLabel('searchHome')
|
||||
|| dateNoteService.getDateNote(today);
|
||||
}
|
||||
|
||||
const {note} = noteService.createNewNote({
|
||||
parentNoteId: searchHome.noteId,
|
||||
@ -112,6 +128,12 @@ function createSearchNote(req) {
|
||||
return note;
|
||||
}
|
||||
|
||||
function getHoistedNote() {
|
||||
return cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root'
|
||||
? repository.getNote(cls.getHoistedNoteId())
|
||||
: null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getInboxNote,
|
||||
getDateNote,
|
||||
|
@ -37,6 +37,7 @@ const BUILTIN_ATTRIBUTES = [
|
||||
{ type: 'label', name: 'workspaceIconClass' },
|
||||
{ type: 'label', name: 'workspaceTabBackgroundColor' },
|
||||
{ type: 'label', name: 'searchHome' },
|
||||
{ type: 'label', name: 'hoistedInbox' },
|
||||
{ type: 'label', name: 'hoistedSearchHome' },
|
||||
{ type: 'label', name: 'sqlConsoleHome' },
|
||||
{ type: 'label', name: 'datePattern' },
|
||||
|
Loading…
x
Reference in New Issue
Block a user