mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
small fixes
This commit is contained in:
parent
cd6d4fb527
commit
fd0bd5dd00
@ -1,8 +1,8 @@
|
|||||||
function isVirtualAttribute(filter) {
|
function isVirtualAttribute(filter) {
|
||||||
return (
|
return (
|
||||||
filter.name == "dateModified"
|
filter.name === "dateModified"
|
||||||
|| filter.name == "dateCreated"
|
|| filter.name === "dateCreated"
|
||||||
|| filter.name == "isProtected"
|
|| filter.name === "isProtected"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
|
|
||||||
const labelRegex = /(\b(and|or)\s+)?@(!?)([\w_-]+|"[^"]+")((=|!=|<|<=|>|>=)([\w_-]+|"[^"]+"))?/i;
|
const labelRegex = /(\b(and|or)\s+)?@(!?)([\w_-]+|"[^"]+")((=|!=|<|<=|>|>=)([\w_-]+|"[^"]+"))?/i;
|
||||||
const smartValueRegex = /^(TODAY|NOW)((\+|\-)(\d+)(H|D|M|Y)){0,1}$/i;
|
const smartValueRegex = /^(TODAY|NOW)(([+\-])(\d+)([HDMY])){0,1}$/i;
|
||||||
|
|
||||||
function calculateSmartValue(v) {
|
function calculateSmartValue(v) {
|
||||||
const normalizedV = v.toUpperCase() + "+0D"; // defaults of sorts
|
const normalizedV = v.toUpperCase() + "+0D"; // defaults of sorts
|
||||||
const [ , keyword, sign, snum, unit] = /(TODAY|NOW)(\+|\-)(\d+)(H|D|M|Y)/.exec(normalizedV);
|
const [ , keyword, sign, snum, unit] = /(TODAY|NOW)([+\-])(\d+)([HDMY])/.exec(normalizedV);
|
||||||
const num = parseInt(snum);
|
const num = parseInt(snum);
|
||||||
|
|
||||||
if (keyword != "TODAY" && keyword != "NOW") {
|
if (keyword !== "TODAY" && keyword !== "NOW") {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ function calculateSmartValue(v) {
|
|||||||
NOW: { D: "days", M: "minutes", H: "hours" }
|
NOW: { D: "days", M: "minutes", H: "hours" }
|
||||||
}[keyword][unit];
|
}[keyword][unit];
|
||||||
|
|
||||||
const format = keyword == "TODAY" ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm";
|
const format = keyword === "TODAY" ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm";
|
||||||
const date = (sign == "+" ? dayjs().add(num, fullUnit) : dayjs().subtract(num, fullUnit));
|
const date = (sign === "+" ? dayjs().add(num, fullUnit) : dayjs().subtract(num, fullUnit));
|
||||||
|
|
||||||
return date.format(format);
|
return date.format(format);
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ module.exports = function(searchText) {
|
|||||||
const relation = match[2] !== undefined ? match[2].toLowerCase() : 'and';
|
const relation = match[2] !== undefined ? match[2].toLowerCase() : 'and';
|
||||||
const operator = match[3] === '!' ? 'not-exists' : 'exists';
|
const operator = match[3] === '!' ? 'not-exists' : 'exists';
|
||||||
|
|
||||||
const value = match[7] !== undefined ? trimQuotes(match[7]) : null
|
const value = match[7] !== undefined ? trimQuotes(match[7]) : null;
|
||||||
|
|
||||||
labelFilters.push({
|
labelFilters.push({
|
||||||
relation: relation,
|
relation: relation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user