From 04c93d6736a5a8e7a86418c93c4ce2bf1e5ef351 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 13 Sep 2020 22:23:03 +0200 Subject: [PATCH] fix attr detail related notes --- src/public/app/services/note_tooltip.js | 5 +++++ src/public/app/widgets/similar_notes.js | 4 ++++ src/routes/api/search.js | 10 ++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/public/app/services/note_tooltip.js b/src/public/app/services/note_tooltip.js index 64d71f78f..46048d87e 100644 --- a/src/public/app/services/note_tooltip.js +++ b/src/public/app/services/note_tooltip.js @@ -84,6 +84,11 @@ async function renderTooltip(note, noteComplement) { } const someNotePath = treeService.getSomeNotePath(note); + + if (!someNotePath) { + return; + } + let content = $("
").text(await treeService.getNotePathTitle(someNotePath)).prop('outerHTML'); const attributes = note.getAttributes() diff --git a/src/public/app/widgets/similar_notes.js b/src/public/app/widgets/similar_notes.js index 4ef0a548d..dd4995480 100644 --- a/src/public/app/widgets/similar_notes.js +++ b/src/public/app/widgets/similar_notes.js @@ -67,6 +67,10 @@ const TPL = ` `; export default class SimilarNotesWidget extends TabAwareWidget { + isEnabled() { + return super.isEnabled() && !this.note.hasLabel('similarNotesWidgetDisabled'); + } + doRender() { this.$widget = $(TPL); this.overflowing(); diff --git a/src/routes/api/search.js b/src/routes/api/search.js index 7237e0053..177e9fc6b 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -119,8 +119,14 @@ async function searchFromRelation(note, relationName) { function getRelatedNotes(req) { const attr = req.body; - const matchingNameAndValue = searchService.searchNotes(formatAttrForSearch(attr, true)); - const matchingName = searchService.searchNotes(formatAttrForSearch(attr, false)); + const searchSettings = { + includeNoteContent: false, + excludeArchived: true, + fuzzyAttributeSearch: false + }; + + const matchingNameAndValue = searchService.findNotesWithQuery(formatAttrForSearch(attr, true), new SearchContext(searchSettings)); + const matchingName = searchService.findNotesWithQuery(formatAttrForSearch(attr, false), new SearchContext(searchSettings)); const results = [];