mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
added "hideRelations" label to relation map
This commit is contained in:
parent
91e3dd022a
commit
a21c49cba7
@ -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",
|
||||
|
@ -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 =>
|
||||
|
@ -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,
|
||||
|
@ -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' },
|
||||
|
Loading…
x
Reference in New Issue
Block a user