mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 06:54:44 +08:00
autocomplete for promoted text labels
This commit is contained in:
parent
90e9297ec5
commit
d3e44b37e9
2 changed files with 21 additions and 1 deletions
|
@ -265,6 +265,26 @@ async function loadAttributes() {
|
||||||
if (valueAttr.type === 'label') {
|
if (valueAttr.type === 'label') {
|
||||||
if (definition.labelType === 'text') {
|
if (definition.labelType === 'text') {
|
||||||
$input.prop("type", "text");
|
$input.prop("type", "text");
|
||||||
|
|
||||||
|
const attributeValues = await server.get('attributes/values/' + encodeURIComponent(valueAttr.name));
|
||||||
|
|
||||||
|
if (attributeValues.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$input.autocomplete({
|
||||||
|
// shouldn't be required and autocomplete should just accept array of strings, but that fails
|
||||||
|
// because we have overriden filter() function in autocomplete.js
|
||||||
|
source: attributeValues.map(attribute => {
|
||||||
|
return {
|
||||||
|
attribute: attribute,
|
||||||
|
value: attribute
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
minLength: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
$input.focus(() => $input.autocomplete("search", ""));
|
||||||
}
|
}
|
||||||
else if (definition.labelType === 'number') {
|
else if (definition.labelType === 'number') {
|
||||||
$input.prop("type", "number");
|
$input.prop("type", "number");
|
||||||
|
|
|
@ -138,7 +138,7 @@ async function getAttributeNames(req) {
|
||||||
async function getValuesForAttribute(req) {
|
async function getValuesForAttribute(req) {
|
||||||
const attributeName = req.params.attributeName;
|
const attributeName = req.params.attributeName;
|
||||||
|
|
||||||
return await sql.getColumn("SELECT DISTINCT value FROM attributes WHERE isDeleted = 0 AND name = ? AND value != '' ORDER BY value", [attributeName]);
|
return await sql.getColumn("SELECT DISTINCT value FROM attributes WHERE isDeleted = 0 AND name = ? AND type = 'label' AND value != '' ORDER BY value", [attributeName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in a new issue