search should find notes in hidden subtree when hoisted into it

This commit is contained in:
zadam 2022-12-23 14:02:18 +01:00
parent 7147cc267e
commit 3804d2df8c
9 changed files with 15 additions and 11 deletions

View File

@ -109,6 +109,7 @@ button.close:hover {
.icon-action { .icon-action {
border: 1px solid transparent; border: 1px solid transparent;
padding: 5px;
width: 35px; width: 35px;
height: 35px; height: 35px;
cursor: pointer; cursor: pointer;

View File

@ -14,7 +14,7 @@ class AncestorExp extends Expression {
this.ancestorDepthComparator = this.getComparator(ancestorDepth); this.ancestorDepthComparator = this.getComparator(ancestorDepth);
} }
execute(inputNoteSet, executionContext) { execute(inputNoteSet, executionContext, searchContext) {
const ancestorNote = becca.notes[this.ancestorNoteId]; const ancestorNote = becca.notes[this.ancestorNoteId];
if (!ancestorNote) { if (!ancestorNote) {

View File

@ -13,7 +13,7 @@ class AttributeExistsExp extends Expression {
this.prefixMatch = prefixMatch; this.prefixMatch = prefixMatch;
} }
execute(inputNoteSet) { execute(inputNoteSet, executionContext, searchContext) {
const attrs = this.prefixMatch const attrs = this.prefixMatch
? becca.findAttributesWithPrefix(this.attributeType, this.attributeName) ? becca.findAttributesWithPrefix(this.attributeType, this.attributeName)
: becca.findAttributes(this.attributeType, this.attributeName); : becca.findAttributes(this.attributeType, this.attributeName);

View File

@ -13,7 +13,7 @@ class LabelComparisonExp extends Expression {
this.comparator = comparator; this.comparator = comparator;
} }
execute(inputNoteSet) { execute(inputNoteSet, executionContext, searchContext) {
const attrs = becca.findAttributes(this.attributeType, this.attributeName); const attrs = becca.findAttributes(this.attributeType, this.attributeName);
const resultNoteSet = new NoteSet(); const resultNoteSet = new NoteSet();

View File

@ -12,7 +12,7 @@ class NoteFlatTextExp extends Expression {
this.tokens = tokens; this.tokens = tokens;
} }
execute(inputNoteSet, executionContext) { execute(inputNoteSet, executionContext, searchContext) {
// has deps on SQL which breaks unit test so needs to be dynamically required // has deps on SQL which breaks unit test so needs to be dynamically required
const beccaService = require('../../../becca/becca_service'); const beccaService = require('../../../becca/becca_service');
const resultNoteSet = new NoteSet(); const resultNoteSet = new NoteSet();

View File

@ -25,11 +25,11 @@ class OrExp extends Expression {
this.subExpressions = subExpressions; this.subExpressions = subExpressions;
} }
execute(inputNoteSet, executionContext) { execute(inputNoteSet, executionContext, searchContext) {
const resultNoteSet = new NoteSet(); const resultNoteSet = new NoteSet();
for (const subExpression of this.subExpressions) { for (const subExpression of this.subExpressions) {
resultNoteSet.mergeIn(subExpression.execute(inputNoteSet, executionContext)); resultNoteSet.mergeIn(subExpression.execute(inputNoteSet, executionContext, searchContext));
} }
return resultNoteSet; return resultNoteSet;

View File

@ -5,8 +5,8 @@ const NoteSet = require('../note_set');
const buildComparator = require("../services/build_comparator"); const buildComparator = require("../services/build_comparator");
/** /**
* Search string is lower cased for case insensitive comparison. But when retrieving properties * Search string is lower cased for case-insensitive comparison. But when retrieving properties
* we need case sensitive form so we have this translation object. * we need case-sensitive form, so we have this translation object.
*/ */
const PROP_MAPPING = { const PROP_MAPPING = {
"noteid": "noteId", "noteid": "noteId",
@ -53,7 +53,7 @@ class PropertyComparisonExp extends Expression {
} }
} }
execute(inputNoteSet, executionContext) { execute(inputNoteSet, executionContext, searchContext) {
const resNoteSet = new NoteSet(); const resNoteSet = new NoteSet();
for (const note of inputNoteSet.notes) { for (const note of inputNoteSet.notes) {

View File

@ -3,7 +3,7 @@
const Expression = require('./expression'); const Expression = require('./expression');
class TrueExp extends Expression { class TrueExp extends Expression {
execute(inputNoteSet, executionContext) { execute(inputNoteSet, executionContext, searchContext) {
return inputNoteSet; return inputNoteSet;
} }
} }

View File

@ -151,6 +151,9 @@ function findResultsWithExpression(expression, searchContext) {
noteIdToNotePath: {} noteIdToNotePath: {}
}; };
const ancestorNote = becca.getNote(searchContext.ancestorNoteId || 'root');
const showNotesInHiddenSubtree = ancestorNote.hasAncestor('_hidden');
const noteSet = expression.execute(allNoteSet, executionContext, searchContext); const noteSet = expression.execute(allNoteSet, executionContext, searchContext);
const searchResults = noteSet.notes const searchResults = noteSet.notes
@ -165,7 +168,7 @@ function findResultsWithExpression(expression, searchContext) {
throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`); throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`);
} }
if (notePathArray.includes('_hidden')) { if (!showNotesInHiddenSubtree && notePathArray.includes('_hidden')) {
return null; return null;
} }