mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix label => attributes omissions
This commit is contained in:
parent
ac25770c0e
commit
7ac109e7f7
@ -14,13 +14,13 @@ const $fileOpen = $("#file-open");
|
|||||||
async function show() {
|
async function show() {
|
||||||
const currentNote = noteDetailService.getCurrentNote();
|
const currentNote = noteDetailService.getCurrentNote();
|
||||||
|
|
||||||
const labels = await server.get('notes/' + currentNote.noteId + '/labels');
|
const attributes = await server.get('notes/' + currentNote.noteId + '/attributes');
|
||||||
const labelMap = utils.toObject(labels, l => [l.name, l.value]);
|
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||||
|
|
||||||
$noteDetailFile.show();
|
$noteDetailFile.show();
|
||||||
|
|
||||||
$fileFileName.text(labelMap.original_file_name);
|
$fileFileName.text(attributeMap.original_file_name);
|
||||||
$fileFileSize.text(labelMap.file_size + " bytes");
|
$fileFileSize.text(attributeMap.file_size + " bytes");
|
||||||
$fileFileType.text(currentNote.mime);
|
$fileFileType.text(currentNote.mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module.exports = function(labelFilters) {
|
module.exports = function(attributeFilters) {
|
||||||
const joins = [];
|
const joins = [];
|
||||||
const joinParams = [];
|
const joinParams = [];
|
||||||
let where = '1';
|
let where = '1';
|
||||||
@ -6,31 +6,31 @@ module.exports = function(labelFilters) {
|
|||||||
|
|
||||||
let i = 1;
|
let i = 1;
|
||||||
|
|
||||||
for (const filter of labelFilters) {
|
for (const filter of attributeFilters) {
|
||||||
joins.push(`LEFT JOIN labels AS label${i} ON label${i}.noteId = notes.noteId AND label${i}.name = ?`);
|
joins.push(`LEFT JOIN attributes AS attribute${i} ON attribute${i}.noteId = notes.noteId AND attribute${i}.name = ?`);
|
||||||
joinParams.push(filter.name);
|
joinParams.push(filter.name);
|
||||||
|
|
||||||
where += " " + filter.relation + " ";
|
where += " " + filter.relation + " ";
|
||||||
|
|
||||||
if (filter.operator === 'exists') {
|
if (filter.operator === 'exists') {
|
||||||
where += `label${i}.labelId IS NOT NULL`;
|
where += `attribute${i}.attributeId IS NOT NULL`;
|
||||||
}
|
}
|
||||||
else if (filter.operator === 'not-exists') {
|
else if (filter.operator === 'not-exists') {
|
||||||
where += `label${i}.labelId IS NULL`;
|
where += `attribute${i}.attributeId IS NULL`;
|
||||||
}
|
}
|
||||||
else if (filter.operator === '=' || filter.operator === '!=') {
|
else if (filter.operator === '=' || filter.operator === '!=') {
|
||||||
where += `label${i}.value ${filter.operator} ?`;
|
where += `attribute${i}.value ${filter.operator} ?`;
|
||||||
whereParams.push(filter.value);
|
whereParams.push(filter.value);
|
||||||
}
|
}
|
||||||
else if ([">", ">=", "<", "<="].includes(filter.operator)) {
|
else if ([">", ">=", "<", "<="].includes(filter.operator)) {
|
||||||
const floatParam = parseFloat(filter.value);
|
const floatParam = parseFloat(filter.value);
|
||||||
|
|
||||||
if (isNaN(floatParam)) {
|
if (isNaN(floatParam)) {
|
||||||
where += `label${i}.value ${filter.operator} ?`;
|
where += `attribute${i}.value ${filter.operator} ?`;
|
||||||
whereParams.push(filter.value);
|
whereParams.push(filter.value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
where += `CAST(label${i}.value AS DECIMAL) ${filter.operator} ?`;
|
where += `CAST(attribute${i}.value AS DECIMAL) ${filter.operator} ?`;
|
||||||
whereParams.push(floatParam);
|
whereParams.push(floatParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,11 @@ async function runNotesWithLabel(runAttrValue) {
|
|||||||
const notes = await repository.getEntities(`
|
const notes = await repository.getEntities(`
|
||||||
SELECT notes.*
|
SELECT notes.*
|
||||||
FROM notes
|
FROM notes
|
||||||
JOIN labels ON labels.noteId = notes.noteId
|
JOIN attributes ON attributes.noteId = notes.noteId
|
||||||
AND labels.isDeleted = 0
|
AND attributes.isDeleted = 0
|
||||||
AND labels.name = 'run'
|
AND attributes.type = 'label'
|
||||||
AND labels.value = ?
|
AND attributes.name = 'run'
|
||||||
|
AND attributes.value = ?
|
||||||
WHERE
|
WHERE
|
||||||
notes.type = 'code'
|
notes.type = 'code'
|
||||||
AND notes.isDeleted = 0`, [runAttrValue]);
|
AND notes.isDeleted = 0`, [runAttrValue]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user