diff --git a/src/becca/becca.js b/src/becca/becca.js index c800ca8a7..f78186061 100644 --- a/src/becca/becca.js +++ b/src/becca/becca.js @@ -29,7 +29,13 @@ class Becca { /** @return {Attribute[]} */ findAttributes(type, name) { - return this.attributeIndex[`${type}-${name.toLowerCase()}`] || []; + name = name.trim().toLowerCase(); + + if (name.startsWith('#') || name.startsWith('~')) { + name = name.substr(1); + } + + return this.attributeIndex[`${type}-${name}`] || []; } /** @return {Attribute[]} */ diff --git a/src/public/app/widgets/ribbon_widgets/edited_notes.js b/src/public/app/widgets/ribbon_widgets/edited_notes.js index 76c396031..629fbeeea 100644 --- a/src/public/app/widgets/ribbon_widgets/edited_notes.js +++ b/src/public/app/widgets/ribbon_widgets/edited_notes.js @@ -33,7 +33,8 @@ export default class EditedNotesWidget extends CollapsibleWidget { getTitle() { return { show: this.isEnabled(), - activate: true, + // promoted attributes have priority over edited notes + activate: this.note.getPromotedDefinitionAttributes().length === 0, title: 'Edited Notes', icon: 'bx bx-calendar-edit' }; diff --git a/src/services/attributes.js b/src/services/attributes.js index ecd8c7689..d2c8ac215 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -75,8 +75,14 @@ function getNoteWithLabel(name, value) { // optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes const attrs = becca.findAttributes('label', name); + if (value === undefined) { + return attrs[0]?.getNote(); + } + + value = value?.toLowerCase(); + for (const attr of attrs) { - if (attr.value === value) { + if (attr.value.toLowerCase() === value) { return attr.getNote(); } } diff --git a/src/services/date_notes.js b/src/services/date_notes.js index 847354dc8..bb19ac547 100644 --- a/src/services/date_notes.js +++ b/src/services/date_notes.js @@ -36,7 +36,6 @@ function getNoteStartingWith(parentNoteId, startsWith) { /** @return {Note} */ function getRootCalendarNote() { - // some caching here could be useful (e.g. in CLS) let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL); if (!rootNote) { diff --git a/src/services/search/expressions/label_comparison.js b/src/services/search/expressions/label_comparison.js index 246797819..1a462af74 100644 --- a/src/services/search/expressions/label_comparison.js +++ b/src/services/search/expressions/label_comparison.js @@ -19,7 +19,7 @@ class LabelComparisonExp extends Expression { for (const attr of attrs) { const note = attr.note; - const value = attr.value ? attr.value.toLowerCase() : attr.value; + const value = attr.value?.toLowerCase(); if (inputNoteSet.hasNoteId(note.noteId) && this.comparator(value)) { if (attr.isInheritable) {