mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
search (note) fixes
This commit is contained in:
parent
16535f6a73
commit
ff5b84db10
@ -357,6 +357,7 @@ function initFancyTree(tree) {
|
|||||||
dnd: dragAndDropSetup,
|
dnd: dragAndDropSetup,
|
||||||
lazyLoad: function(event, data) {
|
lazyLoad: function(event, data) {
|
||||||
const noteId = data.node.data.noteId;
|
const noteId = data.node.data.noteId;
|
||||||
|
|
||||||
data.result = treeCache.getNote(noteId).then(note => treeBuilder.prepareBranch(note));
|
data.result = treeCache.getNote(noteId).then(note => treeBuilder.prepareBranch(note));
|
||||||
},
|
},
|
||||||
clones: {
|
clones: {
|
||||||
|
@ -74,12 +74,17 @@ async function prepareRealBranch(parentNote) {
|
|||||||
|
|
||||||
async function prepareSearchBranch(note) {
|
async function prepareSearchBranch(note) {
|
||||||
const fullNote = await noteDetailService.loadNote(note.noteId);
|
const fullNote = await noteDetailService.loadNote(note.noteId);
|
||||||
const results = await server.get('search/' + encodeURIComponent(fullNote.jsonContent.searchString));
|
const results = (await server.get('search/' + encodeURIComponent(fullNote.jsonContent.searchString)))
|
||||||
|
.filter(res => res.noteId !== note.noteId); // this is necessary because title of the search note is often the same as the search text which would match and create circle
|
||||||
|
|
||||||
const noteIds = results.map(res => res.noteId);
|
const noteIds = results.map(res => res.noteId);
|
||||||
|
|
||||||
|
console.log("result: ", results);
|
||||||
|
|
||||||
// force to load all the notes at once instead of one by one
|
// force to load all the notes at once instead of one by one
|
||||||
await treeCache.getNotes(noteIds);
|
const notes = await treeCache.getNotes(noteIds);
|
||||||
|
|
||||||
|
console.log("NOTES", notes);
|
||||||
|
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
const origBranch = await treeCache.getBranch(result.branchId);
|
const origBranch = await treeCache.getBranch(result.branchId);
|
||||||
@ -95,6 +100,8 @@ async function prepareSearchBranch(note) {
|
|||||||
treeCache.addBranch(branch);
|
treeCache.addBranch(branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("fullNote", fullNote);
|
||||||
|
|
||||||
return await prepareRealBranch(fullNote);
|
return await prepareRealBranch(fullNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ async function searchNotes(req) {
|
|||||||
let results;
|
let results;
|
||||||
|
|
||||||
if (labelFiltersNoteIds && searchTextResults) {
|
if (labelFiltersNoteIds && searchTextResults) {
|
||||||
results = labelFiltersNoteIds.filter(item => searchTextResults.includes(item.noteId));
|
results = searchTextResults.filter(item => labelFiltersNoteIds.includes(item.noteId));
|
||||||
}
|
}
|
||||||
else if (labelFiltersNoteIds) {
|
else if (labelFiltersNoteIds) {
|
||||||
results = labelFiltersNoteIds.map(noteCacheService.getNotePath).filter(res => !!res);
|
results = labelFiltersNoteIds.map(noteCacheService.getNotePath).filter(res => !!res);
|
||||||
@ -64,6 +64,7 @@ async function getFullTextResults(searchText) {
|
|||||||
FROM notes
|
FROM notes
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND isProtected = 0
|
AND isProtected = 0
|
||||||
|
AND type IN ('text', 'code')
|
||||||
AND ${tokenSql.join(' AND ')}`);
|
AND ${tokenSql.join(' AND ')}`);
|
||||||
|
|
||||||
return noteIds;
|
return noteIds;
|
||||||
|
@ -3,6 +3,7 @@ const scriptService = require('./script');
|
|||||||
const treeService = require('./tree');
|
const treeService = require('./tree');
|
||||||
const messagingService = require('./messaging');
|
const messagingService = require('./messaging');
|
||||||
const repository = require('./repository');
|
const repository = require('./repository');
|
||||||
|
const log = require('./log');
|
||||||
|
|
||||||
async function runAttachedRelations(note, relationName, originEntity) {
|
async function runAttachedRelations(note, relationName, originEntity) {
|
||||||
const attributes = await note.getAttributes();
|
const attributes = await note.getAttributes();
|
||||||
@ -11,7 +12,12 @@ async function runAttachedRelations(note, relationName, originEntity) {
|
|||||||
for (const relation of runRelations) {
|
for (const relation of runRelations) {
|
||||||
const scriptNote = await relation.getTargetNote();
|
const scriptNote = await relation.getTargetNote();
|
||||||
|
|
||||||
await scriptService.executeNote(scriptNote, originEntity);
|
if (scriptNote) {
|
||||||
|
await scriptService.executeNote(scriptNote, originEntity);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.error(`Target note ${relation.value} of atttribute ${relation.attributeId} has not been found.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user