Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
added "hideRelations" label to relation map
zadama21c49cba75b
diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.jsindex fd22207c7b..d65d496177 100644--- a/src/public/app/widgets/attribute_widgets/attribute_detail.js+++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js@@ -215,6 +215,8 @@ const ATTR_HELP = {"shareAlias": "define an alias using which the note will be available under https://your_trilium_host/share/[your_alias]","shareOmitDefaultCss": "default share page CSS will be omitted. Use when you make extensive styling changes.","shareRoot": "marks note which is served on /share root.",+ "displayRelations": "comma delimited names of relations which should be displayed. All other ones will be hidden.",+ "hideRelations": "comma delimited names of relations which should be hidden. All other ones will be displayed.",},"relation": {"runOnNoteCreation": "executes when note is created on backend",diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.jsindex 0e2f10a075..dea6665150 100644--- a/src/public/app/widgets/note_detail.js+++ b/src/public/app/widgets/note_detail.js@@ -275,7 +275,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {const label = attrs.find(attr =>attr.type === 'label'- && ['readOnly', 'autoReadOnlyDisabled', 'cssClass', 'displayRelations'].includes(attr.name)+ && ['readOnly', 'autoReadOnlyDisabled', 'cssClass', 'displayRelations', 'hideRelations'].includes(attr.name)&& attributeService.isAffecting(attr, this.note));const relation = attrs.find(attr =>diff --git a/src/routes/api/notes.js b/src/routes/api/notes.jsindex 3a62749a72..f602189e21 100644--- a/src/routes/api/notes.js+++ b/src/routes/api/notes.js@@ -153,7 +153,10 @@ function getRelationMap(req) {.split(",").map(token => token.trim());- console.log("displayRelations", displayRelations);+ const hideRelationsVal = relationMapNote.getLabelValue('hideRelations');+ const hideRelations = !hideRelationsVal ? [] : hideRelationsVal+ .split(",")+ .map(token => token.trim());const foundNoteIds = sql.getColumn(`SELECT noteId FROM notes WHERE isDeleted = 0 AND noteId IN (${questionMarks})`, noteIds);const notes = becca.getNotes(foundNoteIds);@@ -163,7 +166,9 @@ function getRelationMap(req) {resp.relations = resp.relations.concat(note.getRelations().filter(relation => !relation.isAutoLink() || displayRelations.includes(relation.name))- .filter(relation => displayRelations.length === 0 || displayRelations.includes(relation.name))+ .filter(relation => displayRelations.length > 0+ ? displayRelations.includes(relation.name)+ : !hideRelations.includes(relation.name)).filter(relation => noteIds.includes(relation.value)).map(relation => ({attributeId: relation.attributeId,diff --git a/src/services/builtin_attributes.js b/src/services/builtin_attributes.jsindex 51949bb5d0..b988cc8207 100644--- a/src/services/builtin_attributes.js+++ b/src/services/builtin_attributes.js@@ -46,6 +46,8 @@ module.exports = [{ type: 'label', name: 'shareAlias' },{ type: 'label', name: 'shareOmitDefaultCss' },{ type: 'label', name: 'shareRoot' },+ { type: 'label', name: 'displayRelations' },+ { type: 'label', name: 'hideRelations' },// relation names{ type: 'relation', name: 'internalLink' },