set search note title correctly during creation

This commit is contained in:
zadam 2021-02-25 20:02:49 +01:00
parent d0eaf623a8
commit 7572ee284b
5 changed files with 34 additions and 34 deletions

38
package-lock.json generated
View File

@ -1263,9 +1263,9 @@
} }
}, },
"async-mutex": { "async-mutex": {
"version": "0.3.0", "version": "0.3.1",
"resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.0.tgz", "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.1.tgz",
"integrity": "sha512-6VIpUM7s37EMXvnO3TvujgaS6gx4yJby13BhxovMYSap7nrbS0gJ1UzGcjD+HElNSdTz/+IlAIqj7H48N0ZlyQ==", "integrity": "sha512-vRfQwcqBnJTLzVQo72Sf7KIUbcSUP5hNchx6udI1U6LuPQpfePgdjJzlCe76yFZ8pxlLjn9lwcl/Ya0TSOv0Tw==",
"requires": { "requires": {
"tslib": "^2.1.0" "tslib": "^2.1.0"
}, },
@ -1769,9 +1769,9 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001187", "version": "1.0.30001191",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001191.tgz",
"integrity": "sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA==", "integrity": "sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw==",
"dev": true "dev": true
}, },
"caseless": { "caseless": {
@ -3252,9 +3252,9 @@
} }
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.667", "version": "1.3.673",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.667.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.673.tgz",
"integrity": "sha512-Ot1pPtAVb5nd7jeVF651zmfLFilRVFomlDzwXmdlWe5jyzOGa6mVsQ06XnAurT7wWfg5VEIY+LopbAdD/bpo5w==", "integrity": "sha512-ms+QR2ckfrrpEAjXweLx6kNCbpAl66DcW//3BZD4BV5KhUgr0RZRce1ON/9J3QyA3JO28nzgb5Xv8DnPr05ILg==",
"dev": true "dev": true
}, },
"electron-window-state": { "electron-window-state": {
@ -3346,9 +3346,9 @@
} }
}, },
"es-module-lexer": { "es-module-lexer": {
"version": "0.3.26", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.3.26.tgz", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.4.0.tgz",
"integrity": "sha512-Va0Q/xqtrss45hWzP8CZJwzGSZJjDM5/MJRE3IXXnUCcVLElR9BRaE9F62BopysASyc4nM3uwhSW7FFB9nlWAA==", "integrity": "sha512-iuEGihqqhKWFgh72Q/Jtch7V2t/ft8w8IPP2aEN8ArYKO+IWyo6hsi96hCdgyeEDQIV3InhYQ9BlwUFPGXrbEQ==",
"dev": true "dev": true
}, },
"es6-error": { "es6-error": {
@ -5471,9 +5471,9 @@
} }
}, },
"node-releases": { "node-releases": {
"version": "1.1.70", "version": "1.1.71",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.70.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz",
"integrity": "sha512-Slf2s69+2/uAD79pVVQo8uSiC34+g8GWY8UH2Qtqv34ZfhYrxpYpfzs9Js9d6O0mbDmALuxaTlplnBTnSELcrw==", "integrity": "sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==",
"dev": true "dev": true
}, },
"noop-logger": { "noop-logger": {
@ -7662,9 +7662,9 @@
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==" "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
}, },
"webpack": { "webpack": {
"version": "5.23.0", "version": "5.24.2",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.23.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.24.2.tgz",
"integrity": "sha512-RC6dwDuRxiU75F8XC4H08NtzUrMfufw5LDnO8dTtaKU2+fszEdySCgZhNwSBBn516iNaJbQI7T7OPHIgCwcJmg==", "integrity": "sha512-uxxKYEY4kMNjP+D2Y+8aw5Vd7ar4pMuKCNemxV26ysr1nk0YDiQTylg9U3VZIdkmI0YHa0uC8ABxL+uGxGWWJg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -7676,7 +7676,7 @@
"browserslist": "^4.14.5", "browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2", "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.7.0", "enhanced-resolve": "^5.7.0",
"es-module-lexer": "^0.3.26", "es-module-lexer": "^0.4.0",
"eslint-scope": "^5.1.1", "eslint-scope": "^5.1.1",
"events": "^3.2.0", "events": "^3.2.0",
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",

View File

@ -24,7 +24,7 @@
"test-all": "npm run test && npm run test-es6" "test-all": "npm run test && npm run test-es6"
}, },
"dependencies": { "dependencies": {
"async-mutex": "0.3.0", "async-mutex": "0.3.1",
"axios": "0.21.1", "axios": "0.21.1",
"better-sqlite3": "7.1.2", "better-sqlite3": "7.1.2",
"body-parser": "1.19.0", "body-parser": "1.19.0",
@ -87,7 +87,7 @@
"jsdoc": "3.6.6", "jsdoc": "3.6.6",
"lorem-ipsum": "2.0.3", "lorem-ipsum": "2.0.3",
"rcedit": "3.0.0", "rcedit": "3.0.0",
"webpack": "5.23.0", "webpack": "5.24.2",
"webpack-cli": "4.5.0" "webpack-cli": "4.5.0"
}, },
"optionalDependencies": { "optionalDependencies": {

View File

@ -681,7 +681,7 @@ class Note extends Entity {
* Update's given relation's value or creates it if it doesn't exist * Update's given relation's value or creates it if it doesn't exist
* *
* @param {string} name - relation name * @param {string} name - relation name
* @param {string} [value] - relation value (noteId) * @param {string} value - relation value (noteId)
*/ */
setRelation(name, value) { return this.setAttribute(RELATION, name, value); } setRelation(name, value) { return this.setAttribute(RELATION, name, value); }

View File

@ -52,16 +52,7 @@ async function createSqlConsole() {
/** @return {NoteShort} */ /** @return {NoteShort} */
async function createSearchNote(opts = {}) { async function createSearchNote(opts = {}) {
const note = await server.post('search-note'); const note = await server.post('search-note', opts);
const attrsToUpdate = [
opts.ancestorNoteId ? { type: 'relation', name: 'ancestor', value: opts.ancestorNoteId } : undefined,
{ type: 'label', name: 'searchString', value: opts.searchString }
].filter(attr => !!attr);
if (attrsToUpdate.length > 0) {
await server.put(`notes/${note.noteId}/attributes`, attrsToUpdate);
}
await ws.waitForMaxKnownEntityChangeId(); await ws.waitForMaxKnownEntityChangeId();

View File

@ -59,7 +59,10 @@ function createSqlConsole() {
return note; return note;
} }
function createSearchNote() { function createSearchNote(req) {
const params = req.body;
const searchString = params.searchString || "";
const today = dateUtils.localNowDate(); const today = dateUtils.localNowDate();
const searchHome = const searchHome =
@ -68,12 +71,18 @@ function createSearchNote() {
const {note} = noteService.createNewNote({ const {note} = noteService.createNewNote({
parentNoteId: searchHome.noteId, parentNoteId: searchHome.noteId,
title: 'Search: ', title: 'Search: ' + searchString,
content: "", content: "",
type: 'search', type: 'search',
mime: 'application/json' mime: 'application/json'
}); });
note.setLabel('searchString', searchString);
if (params.ancestorNoteId) {
note.setRelation('ancestor', params.ancestorNoteId);
}
return note; return note;
} }