redesign of search input. Saved search is now saved under active note and doesn't need page reload

This commit is contained in:
zadam
2019-03-29 23:24:41 +01:00
parent 8fb6edad67
commit 89b8e2bb08
12 changed files with 104 additions and 69 deletions

View File

@@ -1,6 +1,17 @@
const utils = require('./utils');
const VIRTUAL_ATTRIBUTES = ["dateCreated", "dateCreated", "dateModified", "utcDateCreated", "utcDateModified", "isProtected", "title", "content", "type", "mime", "text"];
const VIRTUAL_ATTRIBUTES = [
"dateCreated",
"dateModified",
"utcDateCreated",
"utcDateModified",
"isProtected",
"title",
"content",
"type",
"mime",
"text"
];
module.exports = function(filters, selectedColumns = 'notes.*') {
// alias => join
@@ -106,7 +117,7 @@ module.exports = function(filters, selectedColumns = 'notes.*') {
else if (filter.operator === '=*' || filter.operator === '!=*') {
where += `${accessor}`
+ (filter.operator.includes('!') ? ' NOT' : '')
+ ` LIKE '` + utils.prepareSqlForLike('', filter.value, '%');
+ ` LIKE ` + utils.prepareSqlForLike('', filter.value, '%');
}
else if (filter.operator === '*=*' || filter.operator === '!*=*') {
where += `${accessor}`
@@ -149,8 +160,5 @@ module.exports = function(filters, selectedColumns = 'notes.*') {
GROUP BY notes.noteId
ORDER BY ${orderBy.join(", ")}`;
console.log(query);
console.log(params);
return { query, params };
};

View File

@@ -77,6 +77,18 @@ async function createNewNote(parentNoteId, noteData) {
}
}
if (!noteData.mime) {
if (noteData.type === 'text') {
noteData.mime = 'text/html';
}
else if (noteData.type === 'code') {
noteData.mime = 'text/plain';
}
else if (noteData.type === 'relation-map' || noteData.type === 'search') {
noteData.mime = 'application/json';
}
}
noteData.type = noteData.type || parentNote.type;
noteData.mime = noteData.mime || parentNote.mime;

View File

@@ -1,6 +1,6 @@
const dayjs = require("dayjs");
const filterRegex = /(\b(AND|OR)\s+)?@(!?)([\w_]+|"[^"]+")\s*((=|!=|<|<=|>|>=|!?\*=|!?=\*|!?\*=\*)\s*([\w_-]+|"[^"]+"))?/ig;
const filterRegex = /(\b(AND|OR)\s+)?@(!?)([\w_]+|"[^"]+")\s*((=|!=|<|<=|>|>=|!?\*=|!?=\*|!?\*=\*)\s*([\w_/-]+|"[^"]+"))?/ig;
const smartValueRegex = /^(NOW|TODAY|WEEK|MONTH|YEAR) *([+\-] *\d+)?$/i;
function calculateSmartValue(v) {