added "type" to attribute dialog, name autocomplete servers according to the choice

This commit is contained in:
azivner
2018-08-03 11:11:57 +02:00
parent 097114c0f2
commit 509093b755
8 changed files with 623 additions and 233 deletions

View File

@@ -42,18 +42,11 @@ async function updateNoteAttributes(req) {
return await repository.getEntities("SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ? ORDER BY position, dateCreated", [noteId]);
}
async function getAllAttributeNames() {
const names = await sql.getColumn("SELECT DISTINCT name FROM attributes WHERE isDeleted = 0");
async function getAttributeNames(req) {
const type = req.query.type;
const query = req.query.query;
for (const attribute of attributeService.BUILTIN_ATTRIBUTES) {
if (!names.includes(attribute)) {
names.push(attribute);
}
}
names.sort();
return names;
return attributeService.getAttributeNames(type, query);
}
async function getValuesForAttribute(req) {
@@ -65,6 +58,6 @@ async function getValuesForAttribute(req) {
module.exports = {
getNoteAttributes,
updateNoteAttributes,
getAllAttributeNames,
getAttributeNames,
getValuesForAttribute
};