mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
added "type" to attribute dialog, name autocomplete servers according to the choice
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
const repository = require('./repository');
|
||||
const sql = require('./sql');
|
||||
const utils = require('./utils');
|
||||
const Attribute = require('../entities/attribute');
|
||||
|
||||
const BUILTIN_ATTRIBUTES = [
|
||||
'disableVersioning',
|
||||
'calendarRoot',
|
||||
'archived',
|
||||
'excludeFromExport',
|
||||
'run',
|
||||
'manualTransactionHandling',
|
||||
'disableInclusion',
|
||||
'appCss',
|
||||
'hideChildrenOverview'
|
||||
// label names
|
||||
{ type: 'label', name: 'disableVersioning' },
|
||||
{ type: 'label', name: 'calendarRoot' },
|
||||
{ type: 'label', name: 'archived' },
|
||||
{ type: 'label', name: 'excludeFromExport' },
|
||||
{ type: 'label', name: 'run' },
|
||||
{ type: 'label', name: 'manualTransactionHandling' },
|
||||
{ type: 'label', name: 'disableInclusion' },
|
||||
{ type: 'label', name: 'appCss' },
|
||||
{ type: 'label', name: 'hideChildrenOverview' },
|
||||
|
||||
// relation names
|
||||
{ type: 'relation', name: 'runOnNoteView' },
|
||||
{ type: 'relation', name: 'runOnNoteTitleChange' }
|
||||
];
|
||||
|
||||
async function getNotesWithAttribute(name, value) {
|
||||
@@ -44,9 +51,29 @@ async function createAttribute(noteId, name, value = "") {
|
||||
}).save();
|
||||
}
|
||||
|
||||
async function getAttributeNames(type, nameLike) {
|
||||
const names = await sql.getColumn(
|
||||
`SELECT DISTINCT name
|
||||
FROM attributes
|
||||
WHERE isDeleted = 0
|
||||
AND type = ?
|
||||
AND name LIKE '%${utils.sanitizeSql(nameLike)}%'`, [ type ]);
|
||||
|
||||
for (const attribute of BUILTIN_ATTRIBUTES) {
|
||||
if (attribute.type === type && !names.includes(attribute.name)) {
|
||||
names.push(attribute.name);
|
||||
}
|
||||
}
|
||||
|
||||
names.sort();
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getNotesWithAttribute,
|
||||
getNoteWithAttribute,
|
||||
createAttribute,
|
||||
getAttributeNames,
|
||||
BUILTIN_ATTRIBUTES
|
||||
};
|
||||
Reference in New Issue
Block a user