mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	hide auto links by default in relation map, allow configuring displayed relations, fixes #1674
This commit is contained in:
		| @@ -276,7 +276,7 @@ export default class NoteDetailWidget extends TabAwareWidget { | |||||||
|  |  | ||||||
|             const label = attrs.find(attr => |             const label = attrs.find(attr => | ||||||
|                 attr.type === 'label' |                 attr.type === 'label' | ||||||
|                 && ['readOnly', 'autoReadOnlyDisabled', 'cssClass', 'bookZoomLevel'].includes(attr.name) |                 && ['readOnly', 'autoReadOnlyDisabled', 'cssClass', 'bookZoomLevel', 'displayRelations'].includes(attr.name) | ||||||
|                 && attr.isAffecting(this.note)); |                 && attr.isAffecting(this.note)); | ||||||
|  |  | ||||||
|             const relation = attrs.find(attr => |             const relation = attrs.find(attr => | ||||||
|   | |||||||
| @@ -285,7 +285,7 @@ export default class RelationMapTypeWidget extends TypeWidget { | |||||||
|  |  | ||||||
|     async loadNotesAndRelations() { |     async loadNotesAndRelations() { | ||||||
|         const noteIds = this.mapData.notes.map(note => note.noteId); |         const noteIds = this.mapData.notes.map(note => note.noteId); | ||||||
|         const data = await server.post("notes/relation-map", {noteIds}); |         const data = await server.post("notes/relation-map", {noteIds, relationMapNoteId: this.noteId}); | ||||||
|  |  | ||||||
|         this.relations = []; |         this.relations = []; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -117,7 +117,8 @@ function setNoteTypeMime(req) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function getRelationMap(req) { | function getRelationMap(req) { | ||||||
|     const noteIds = req.body.noteIds; |     const {relationMapNoteId, noteIds} = req.body; | ||||||
|  |  | ||||||
|     const resp = { |     const resp = { | ||||||
|         // noteId => title |         // noteId => title | ||||||
|         noteTitles: {}, |         noteTitles: {}, | ||||||
| @@ -134,12 +135,23 @@ function getRelationMap(req) { | |||||||
|  |  | ||||||
|     const questionMarks = noteIds.map(noteId => '?').join(','); |     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); |     const notes = repository.getEntities(`SELECT * FROM notes WHERE isDeleted = 0 AND noteId IN (${questionMarks})`, noteIds); | ||||||
|  |  | ||||||
|     for (const note of notes) { |     for (const note of notes) { | ||||||
|         resp.noteTitles[note.noteId] = note.title; |         resp.noteTitles[note.noteId] = note.title; | ||||||
|  |  | ||||||
|         resp.relations = resp.relations.concat(note.getRelations() |         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)) |             .filter(relation => noteIds.includes(relation.value)) | ||||||
|             .map(relation => ({ |             .map(relation => ({ | ||||||
|                 attributeId: relation.attributeId, |                 attributeId: relation.attributeId, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user