Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
new attribute "hide_in_autocomplete", fixes #16
azivner2e8eeda5ab02
diff --git a/db/migrations/0076__add_attribute_name_index.sql b/db/migrations/0076__add_attribute_name_index.sqlnew file mode 100644index 0000000000..6911a3f2c6--- /dev/null+++ b/db/migrations/0076__add_attribute_name_index.sql@@ -0,0 +1 @@+CREATE INDEX IDX_attributes_name_value ON attributes (name, value);\ No newline at end of filediff --git a/db/schema.sql b/db/schema.sqlindex 58d07f99bc..12cd0c9e63 100644--- a/db/schema.sql+++ b/db/schema.sql@@ -120,6 +120,7 @@ CREATE INDEX IDX_note_images_noteId ON note_images (noteId);CREATE INDEX IDX_note_images_imageId ON note_images (imageId);CREATE INDEX IDX_note_images_noteId_imageId ON note_images (noteId, imageId);CREATE INDEX IDX_attributes_noteId ON attributes (noteId);+CREATE INDEX IDX_attributes_name_value ON attributes (name, value);CREATE TABLE IF NOT EXISTS "api_tokens"(diff --git a/src/public/javascripts/note_tree.js b/src/public/javascripts/note_tree.jsindex e2a4bf3ba1..749867d3a3 100644--- a/src/public/javascripts/note_tree.js+++ b/src/public/javascripts/note_tree.js@@ -14,6 +14,8 @@ const noteTree = (function() {let parentChildToNoteTreeId = {};let noteIdToTitle = {};+ let hiddenInAutocomplete = {};+function getNoteTreeId(parentNoteId, childNoteId) {assertArguments(parentNoteId, childNoteId);@@ -648,6 +650,12 @@ const noteTree = (function() {startNotePath = getNotePathFromAddress();}+ hiddenInAutocomplete = {};++ for (const noteId of resp.hiddenInAutocomplete) {+ hiddenInAutocomplete[noteId] = true;+ }+return prepareNoteTree(resp.notes);}@@ -705,6 +713,10 @@ const noteTree = (function() {const autocompleteItems = [];for (const childNoteId of parentToChildren[parentNoteId]) {+ if (hiddenInAutocomplete[childNoteId]) {+ continue;+ }+const childNotePath = (notePath ? (notePath + '/') : '') + childNoteId;const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + getNoteTitle(childNoteId, parentNoteId);diff --git a/src/routes/api/tree.js b/src/routes/api/tree.jsindex b78ee096c4..e9db493abf 100644--- a/src/routes/api/tree.js+++ b/src/routes/api/tree.js@@ -29,8 +29,20 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {protected_session.decryptNotes(req, notes);+ const hiddenInAutocomplete = await sql.getColumn(`+ SELECT+ DISTINCT noteId+ FROM+ attributes+ JOIN notes USING(noteId)+ WHERE+ attributes.name = 'hide_in_autocomplete'+ AND attributes.isDeleted = 0+ AND notes.isDeleted = 0`);+res.send({notes: notes,+ hiddenInAutocomplete: hiddenInAutocomplete,start_note_path: await options.getOption('start_note_path')});}));diff --git a/src/services/app_info.js b/src/services/app_info.jsindex dfac4ab374..86f357af01 100644--- a/src/services/app_info.js+++ b/src/services/app_info.js@@ -3,7 +3,7 @@const build = require('./build');const packageJson = require('../../package');-const APP_DB_VERSION = 75;+const APP_DB_VERSION = 76;module.exports = {app_version: packageJson.version,diff --git a/src/services/attributes.js b/src/services/attributes.jsindex eb256599a1..12f19bba58 100644--- a/src/services/attributes.js+++ b/src/services/attributes.js@@ -5,7 +5,12 @@ const utils = require('./utils');const sync_table = require('./sync_table');const Repository = require('./repository');-const BUILTIN_ATTRIBUTES = [ 'run_on_startup', 'disable_versioning', 'calendar_root' ];+const BUILTIN_ATTRIBUTES = [+ 'run_on_startup',+ 'disable_versioning',+ 'calendar_root',+ 'hide_in_autocomplete'+];async function getNoteAttributeMap(noteId) {return await sql.getMap(`SELECT name, value FROM attributes WHERE noteId = ?`, [noteId]);