mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 01:36:24 +01:00
hide auto links by default in relation map, allow configuring displayed relations, fixes #1674
This commit is contained in:
@@ -117,7 +117,8 @@ function setNoteTypeMime(req) {
|
||||
}
|
||||
|
||||
function getRelationMap(req) {
|
||||
const noteIds = req.body.noteIds;
|
||||
const {relationMapNoteId, noteIds} = req.body;
|
||||
|
||||
const resp = {
|
||||
// noteId => title
|
||||
noteTitles: {},
|
||||
@@ -134,12 +135,23 @@ function getRelationMap(req) {
|
||||
|
||||
const questionMarks = noteIds.map(noteId => '?').join(',');
|
||||
|
||||
const relationMapNote = repository.getNote(relationMapNoteId);
|
||||
|
||||
const displayRelationsVal = relationMapNote.getLabelValue('displayRelations');
|
||||
const displayRelations = !displayRelationsVal ? [] : displayRelationsVal
|
||||
.split(",")
|
||||
.map(token => token.trim());
|
||||
|
||||
console.log("displayRelations", displayRelations);
|
||||
|
||||
const notes = repository.getEntities(`SELECT * FROM notes WHERE isDeleted = 0 AND noteId IN (${questionMarks})`, noteIds);
|
||||
|
||||
for (const note of notes) {
|
||||
resp.noteTitles[note.noteId] = note.title;
|
||||
|
||||
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 => noteIds.includes(relation.value))
|
||||
.map(relation => ({
|
||||
attributeId: relation.attributeId,
|
||||
|
||||
Reference in New Issue
Block a user