mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
new attribute "hide_in_autocomplete", fixes #16
This commit is contained in:
parent
1cef0ce5f9
commit
2e8eeda5ab
1
db/migrations/0076__add_attribute_name_index.sql
Normal file
1
db/migrations/0076__add_attribute_name_index.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
CREATE INDEX IDX_attributes_name_value ON attributes (name, value);
|
@ -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_imageId ON note_images (imageId);
|
||||||
CREATE INDEX IDX_note_images_noteId_imageId ON note_images (noteId, 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_noteId ON attributes (noteId);
|
||||||
|
CREATE INDEX IDX_attributes_name_value ON attributes (name, value);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "api_tokens"
|
CREATE TABLE IF NOT EXISTS "api_tokens"
|
||||||
(
|
(
|
||||||
|
@ -14,6 +14,8 @@ const noteTree = (function() {
|
|||||||
let parentChildToNoteTreeId = {};
|
let parentChildToNoteTreeId = {};
|
||||||
let noteIdToTitle = {};
|
let noteIdToTitle = {};
|
||||||
|
|
||||||
|
let hiddenInAutocomplete = {};
|
||||||
|
|
||||||
function getNoteTreeId(parentNoteId, childNoteId) {
|
function getNoteTreeId(parentNoteId, childNoteId) {
|
||||||
assertArguments(parentNoteId, childNoteId);
|
assertArguments(parentNoteId, childNoteId);
|
||||||
|
|
||||||
@ -648,6 +650,12 @@ const noteTree = (function() {
|
|||||||
startNotePath = getNotePathFromAddress();
|
startNotePath = getNotePathFromAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hiddenInAutocomplete = {};
|
||||||
|
|
||||||
|
for (const noteId of resp.hiddenInAutocomplete) {
|
||||||
|
hiddenInAutocomplete[noteId] = true;
|
||||||
|
}
|
||||||
|
|
||||||
return prepareNoteTree(resp.notes);
|
return prepareNoteTree(resp.notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,6 +713,10 @@ const noteTree = (function() {
|
|||||||
const autocompleteItems = [];
|
const autocompleteItems = [];
|
||||||
|
|
||||||
for (const childNoteId of parentToChildren[parentNoteId]) {
|
for (const childNoteId of parentToChildren[parentNoteId]) {
|
||||||
|
if (hiddenInAutocomplete[childNoteId]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const childNotePath = (notePath ? (notePath + '/') : '') + childNoteId;
|
const childNotePath = (notePath ? (notePath + '/') : '') + childNoteId;
|
||||||
const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + getNoteTitle(childNoteId, parentNoteId);
|
const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + getNoteTitle(childNoteId, parentNoteId);
|
||||||
|
|
||||||
|
@ -29,8 +29,20 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
|
|||||||
|
|
||||||
protected_session.decryptNotes(req, notes);
|
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({
|
res.send({
|
||||||
notes: notes,
|
notes: notes,
|
||||||
|
hiddenInAutocomplete: hiddenInAutocomplete,
|
||||||
start_note_path: await options.getOption('start_note_path')
|
start_note_path: await options.getOption('start_note_path')
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const build = require('./build');
|
const build = require('./build');
|
||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
|
|
||||||
const APP_DB_VERSION = 75;
|
const APP_DB_VERSION = 76;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
app_version: packageJson.version,
|
app_version: packageJson.version,
|
||||||
|
@ -5,7 +5,12 @@ const utils = require('./utils');
|
|||||||
const sync_table = require('./sync_table');
|
const sync_table = require('./sync_table');
|
||||||
const Repository = require('./repository');
|
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) {
|
async function getNoteAttributeMap(noteId) {
|
||||||
return await sql.getMap(`SELECT name, value FROM attributes WHERE noteId = ?`, [noteId]);
|
return await sql.getMap(`SELECT name, value FROM attributes WHERE noteId = ?`, [noteId]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user