mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
search definition refactoring
This commit is contained in:
parent
cf5127dcec
commit
ec351137d4
56
package-lock.json
generated
56
package-lock.json
generated
@ -636,9 +636,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/estree": {
|
"@types/estree": {
|
||||||
"version": "0.0.45",
|
"version": "0.0.46",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.45.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.46.tgz",
|
||||||
"integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==",
|
"integrity": "sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/fs-extra": {
|
"@types/fs-extra": {
|
||||||
@ -668,9 +668,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/json-schema": {
|
"@types/json-schema": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz",
|
||||||
"integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
|
"integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/keyv": {
|
"@types/keyv": {
|
||||||
@ -1769,9 +1769,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"caniuse-lite": {
|
"caniuse-lite": {
|
||||||
"version": "1.0.30001178",
|
"version": "1.0.30001179",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001178.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001179.tgz",
|
||||||
"integrity": "sha512-VtdZLC0vsXykKni8Uztx45xynytOi71Ufx9T8kHptSw9AL4dpqailUJJHavttuzUe1KYuBYtChiWv+BAb7mPmQ==",
|
"integrity": "sha512-blMmO0QQujuUWZKyVrD1msR4WNDAqb/UPO1Sw2WWsQ7deoM5bJiicKnWJ1Y0NS/aGINSnKPIWBMw5luX+NDUCA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"caseless": {
|
"caseless": {
|
||||||
@ -3208,9 +3208,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron-to-chromium": {
|
"electron-to-chromium": {
|
||||||
"version": "1.3.641",
|
"version": "1.3.645",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.641.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.645.tgz",
|
||||||
"integrity": "sha512-b0DLhsHSHESC1I+Nx6n4w4Lr61chMd3m/av1rZQhS2IXTzaS5BMM5N+ldWdMIlni9CITMRM09m8He4+YV/92TA==",
|
"integrity": "sha512-T7mYop3aDpRHIQaUYcmzmh6j9MAe560n6ukqjJMbVC6bVTau7dSpvB18bcsBPPtOSe10cKxhJFtlbEzLa0LL1g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"electron-window-state": {
|
"electron-window-state": {
|
||||||
@ -6002,9 +6002,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"postcss": {
|
"postcss": {
|
||||||
"version": "8.2.1",
|
"version": "8.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.4.tgz",
|
||||||
"integrity": "sha512-RhsqOOAQzTgh1UB/IZdca7F9WDb7SUCR2Vnv1x7DbvuuggQIpoDwjK+q0rzoPffhYvWNKX5JSwS4so4K3UC6vA==",
|
"integrity": "sha512-kRFftRoExRVXZlwUuay9iC824qmXPcQQVzAjbCCgjpXnkdMCJYBu2gTwAaFBzv8ewND6O8xFb3aELmEkh9zTzg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"colorette": "^1.2.1",
|
"colorette": "^1.2.1",
|
||||||
"nanoid": "^3.1.20",
|
"nanoid": "^3.1.20",
|
||||||
@ -6525,9 +6525,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sanitize-html": {
|
"sanitize-html": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.3.1.tgz",
|
||||||
"integrity": "sha512-JAsbaKskfxR+ZhEnqO/T3c2dKalVDA6sXIgy/27TatIUzOPO/zWr1r8Ykzp1cwJx1j+DPMQF5ifvhniixRWYDA==",
|
"integrity": "sha512-JYziKrrtCEGhrsUAZK1mL0RdEcRxBGZ+ptgppv7ulAsan7MZVL+oVKRSPCIcYinfM1rVOMYh5dHLydMuHaQOUA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"deepmerge": "^4.2.2",
|
"deepmerge": "^4.2.2",
|
||||||
"escape-string-regexp": "^4.0.0",
|
"escape-string-regexp": "^4.0.0",
|
||||||
@ -6572,9 +6572,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entities": {
|
"entities": {
|
||||||
"version": "2.1.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
|
||||||
"integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w=="
|
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
|
||||||
},
|
},
|
||||||
"escape-string-regexp": {
|
"escape-string-regexp": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
@ -7680,13 +7680,13 @@
|
|||||||
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
|
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
|
||||||
},
|
},
|
||||||
"webpack": {
|
"webpack": {
|
||||||
"version": "5.16.0",
|
"version": "5.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.16.0.tgz",
|
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.17.0.tgz",
|
||||||
"integrity": "sha512-QOkctcjYfEGxcYg4AzPJafyAQ7ANc266/URkX881uFA7b2k31E0Dmpy1ExfppHOTp1kHDTsRh9sXojVUvgPF0g==",
|
"integrity": "sha512-R+IdNEaYcYaACpXZOt7reyc8txBK7J06lOPkX1SbgmeoAnUbyBZivJIksrDBnmMA3wlTWvPcX7DubxELyPB8rA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/eslint-scope": "^3.7.0",
|
"@types/eslint-scope": "^3.7.0",
|
||||||
"@types/estree": "^0.0.45",
|
"@types/estree": "^0.0.46",
|
||||||
"@webassemblyjs/ast": "1.11.0",
|
"@webassemblyjs/ast": "1.11.0",
|
||||||
"@webassemblyjs/wasm-edit": "1.11.0",
|
"@webassemblyjs/wasm-edit": "1.11.0",
|
||||||
"@webassemblyjs/wasm-parser": "1.11.0",
|
"@webassemblyjs/wasm-parser": "1.11.0",
|
||||||
@ -7712,9 +7712,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "8.0.4",
|
"version": "8.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.5.tgz",
|
||||||
"integrity": "sha512-XNP0PqF1XD19ZlLKvB7cMmnZswW4C/03pRHgirB30uSJTaS3A3V1/P4sS3HPvFmjoriPCJQs+JDSbm4bL1TxGQ==",
|
"integrity": "sha512-v+DieK/HJkJOpFBETDJioequtc3PfxsWMaxIdIwujtF7FEV/MAyDQLlm6/zPvr7Mix07mLh6ccVwIsloceodlg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"graceful-fs": {
|
"graceful-fs": {
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"sanitize-filename": "1.6.3",
|
"sanitize-filename": "1.6.3",
|
||||||
"sanitize-html": "2.3.0",
|
"sanitize-html": "2.3.1",
|
||||||
"sax": "1.2.4",
|
"sax": "1.2.4",
|
||||||
"semver": "7.3.4",
|
"semver": "7.3.4",
|
||||||
"serve-favicon": "2.5.0",
|
"serve-favicon": "2.5.0",
|
||||||
@ -86,7 +86,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.16.0",
|
"webpack": "5.17.0",
|
||||||
"webpack-cli": "4.4.0"
|
"webpack-cli": "4.4.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
@ -48,7 +48,7 @@ async function createSearchNote(opts = {}) {
|
|||||||
|
|
||||||
const attrsToUpdate = [
|
const attrsToUpdate = [
|
||||||
opts.ancestor ? { type: 'relation', name: 'ancestor', value: opts.ancestorNoteId } : undefined,
|
opts.ancestor ? { type: 'relation', name: 'ancestor', value: opts.ancestorNoteId } : undefined,
|
||||||
opts.searchString ? { type: 'label', name: 'searchString', value: opts.searchString } : undefined
|
{ type: 'label', name: 'searchString', value: opts.searchString }
|
||||||
].filter(attr => !!attr);
|
].filter(attr => !!attr);
|
||||||
|
|
||||||
if (attrsToUpdate.length > 0) {
|
if (attrsToUpdate.length > 0) {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import ws from "../../services/ws.js";
|
import ws from "../../services/ws.js";
|
||||||
|
import Component from "../component.js";
|
||||||
|
|
||||||
export default class AbstractAction {
|
export default class AbstractSearchAction extends Component {
|
||||||
constructor(attribute, actionDef) {
|
constructor(attribute, actionDef) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
this.actionDef = actionDef;
|
this.actionDef = actionDef;
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -21,7 +21,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class DeleteLabelSearchAction extends AbstractAction {
|
export default class DeleteLabelSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "deleteLabel"; }
|
static get actionName() { return "deleteLabel"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -12,7 +12,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class DeleteNoteSearchAction extends AbstractAction {
|
export default class DeleteNoteSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "deleteNote"; }
|
static get actionName() { return "deleteNote"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -21,7 +21,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class DeleteRelationSearchAction extends AbstractAction {
|
export default class DeleteRelationSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "deleteRelation"; }
|
static get actionName() { return "deleteRelation"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -20,7 +20,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class ExecuteScriptSearchAction extends AbstractAction {
|
export default class ExecuteScriptSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "executeScript"; }
|
static get actionName() { return "executeScript"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -32,7 +32,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class RenameLabelSearchAction extends AbstractAction {
|
export default class RenameLabelSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "renameLabel"; }
|
static get actionName() { return "renameLabel"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -32,7 +32,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class RenameRelationSearchAction extends AbstractAction {
|
export default class RenameRelationSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "renameRelation"; }
|
static get actionName() { return "renameRelation"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<tr>
|
<tr>
|
||||||
@ -28,7 +28,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class SetLabelValueSearchAction extends AbstractAction {
|
export default class SetLabelValueSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "setLabelValue"; }
|
static get actionName() { return "setLabelValue"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import SpacedUpdate from "../../services/spaced_update.js";
|
import SpacedUpdate from "../../services/spaced_update.js";
|
||||||
import AbstractAction from "./abstract_action.js";
|
import AbstractSearchAction from "./abstract_search_action.js";
|
||||||
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
@ -28,7 +28,7 @@ const TPL = `
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
export default class SetRelationTargetSearchAction extends AbstractAction {
|
export default class SetRelationTargetSearchAction extends AbstractSearchAction {
|
||||||
static get actionName() { return "setRelationTarget"; }
|
static get actionName() { return "setRelationTarget"; }
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -182,6 +182,24 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$widget.on('click', '[data-action-add]', async event => {
|
||||||
|
const actionName = $(event.target).attr('data-action-add');
|
||||||
|
|
||||||
|
await server.post(`notes/${this.noteId}/attributes`, {
|
||||||
|
type: 'label',
|
||||||
|
name: 'action',
|
||||||
|
value: JSON.stringify({
|
||||||
|
name: actionName
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$widget.find('.action-add-toggle').dropdown('toggle');
|
||||||
|
|
||||||
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
this.$widget.on('click', '[data-search-option-del]', async event => {
|
this.$widget.on('click', '[data-search-option-del]', async event => {
|
||||||
async function deleteAttr(note, attrName) {
|
async function deleteAttr(note, attrName) {
|
||||||
for (const attr of note.getOwnedAttributes()) {
|
for (const attr of note.getOwnedAttributes()) {
|
||||||
@ -204,28 +222,6 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$searchOptions = this.$widget.find('.search-options');
|
|
||||||
|
|
||||||
this.$actionOptions = this.$widget.find('.action-options');
|
|
||||||
|
|
||||||
this.$widget.on('click', '[data-action-add]', async event => {
|
|
||||||
const actionName = $(event.target).attr('data-action-add');
|
|
||||||
|
|
||||||
await server.post(`notes/${this.noteId}/attributes`, {
|
|
||||||
type: 'label',
|
|
||||||
name: 'action',
|
|
||||||
value: JSON.stringify({
|
|
||||||
name: actionName
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$widget.find('.action-add-toggle').dropdown('toggle');
|
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
|
||||||
|
|
||||||
this.refresh();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$widget.on('click', '[data-action-conf-del]', async event => {
|
this.$widget.on('click', '[data-action-conf-del]', async event => {
|
||||||
const attributeId = $(event.target).closest('[data-attribute-id]').attr('data-attribute-id');
|
const attributeId = $(event.target).closest('[data-attribute-id]').attr('data-attribute-id');
|
||||||
|
|
||||||
@ -236,14 +232,17 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$searchOptions = this.$widget.find('.search-options');
|
||||||
|
this.$actionOptions = this.$widget.find('.action-options');
|
||||||
|
|
||||||
this.$searchButton = this.$widget.find('.search-button');
|
this.$searchButton = this.$widget.find('.search-button');
|
||||||
this.$searchButton.on('click', () => this.refreshResults());
|
this.$searchButton.on('click', () => this.triggerCommand('refreshResults'));
|
||||||
|
|
||||||
this.$searchAndExecuteButton = this.$widget.find('.search-and-execute-button');
|
this.$searchAndExecuteButton = this.$widget.find('.search-and-execute-button');
|
||||||
this.$searchAndExecuteButton.on('click', () => this.searchAndExecute());
|
this.$searchAndExecuteButton.on('click', () => this.searchAndExecute());
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshResults() {
|
async refreshResultsCommand() {
|
||||||
await treeCache.reloadNotes([this.noteId]);
|
await treeCache.reloadNotes([this.noteId]);
|
||||||
|
|
||||||
this.triggerEvent('searchRefreshed', {tabId: this.tabContext.tabId});
|
this.triggerEvent('searchRefreshed', {tabId: this.tabContext.tabId});
|
||||||
@ -260,9 +259,10 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
|
|||||||
const attr = this.note.getAttribute(attributeType, optionName);
|
const attr = this.note.getAttribute(attributeType, optionName);
|
||||||
|
|
||||||
this.$widget.find(`[data-search-option-add='${optionName}'`).toggle(!attr);
|
this.$widget.find(`[data-search-option-add='${optionName}'`).toggle(!attr);
|
||||||
console.log(optionName, attr);
|
|
||||||
if (attr) {
|
if (attr) {
|
||||||
const searchOption = new OptionClass(attr, this.note);
|
const searchOption = new OptionClass(attr, this.note).setParent(this);
|
||||||
|
this.child(searchOption);
|
||||||
|
|
||||||
this.$searchOptions.append(searchOption.render());
|
this.$searchOptions.append(searchOption.render());
|
||||||
}
|
}
|
||||||
@ -290,7 +290,8 @@ console.log(optionName, attr);
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const action = new ActionClass(actionAttr, actionDef);
|
const action = new ActionClass(actionAttr, actionDef).setParent(this);
|
||||||
|
this.child(action);
|
||||||
|
|
||||||
this.$actionOptions.append(action.render());
|
this.$actionOptions.append(action.render());
|
||||||
}
|
}
|
||||||
@ -298,11 +299,6 @@ console.log(optionName, attr);
|
|||||||
this.$searchAndExecuteButton.css('visibility', actionLabels.length > 0 ? 'visible' : 'hidden');
|
this.$searchAndExecuteButton.css('visibility', actionLabels.length > 0 ? 'visible' : 'hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
focusOnSearchDefinitionEvent() {
|
|
||||||
// FIXME
|
|
||||||
this.$searchString.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
getContent() {
|
getContent() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -310,7 +306,7 @@ console.log(optionName, attr);
|
|||||||
async searchAndExecute() {
|
async searchAndExecute() {
|
||||||
await server.post(`search-and-execute-note/${this.noteId}`);
|
await server.post(`search-and-execute-note/${this.noteId}`);
|
||||||
|
|
||||||
this.refreshResults();
|
this.triggerCommand('refreshResults');
|
||||||
|
|
||||||
toastService.showMessage('Actions have been executed.', 3000);
|
toastService.showMessage('Actions have been executed.', 3000);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import ws from "../../services/ws.js";
|
import ws from "../../services/ws.js";
|
||||||
|
import Component from "../component.js";
|
||||||
|
|
||||||
export default class AbstractSearchOption {
|
export default class AbstractSearchOption extends Component {
|
||||||
constructor(attribute, note) {
|
constructor(attribute, note) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
this.note = note;
|
this.note = note;
|
||||||
}
|
}
|
||||||
@ -13,6 +16,10 @@ export default class AbstractSearchOption {
|
|||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setAttribute(type, name, value = '') {
|
||||||
|
await this.constructor.setAttribute(this.note.noteId, type, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
try {
|
try {
|
||||||
const $rendered = this.doRender();
|
const $rendered = this.doRender();
|
||||||
|
@ -41,17 +41,17 @@ export default class SearchString extends AbstractSearchOption {
|
|||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
const $option = $(TPL);
|
const $option = $(TPL);
|
||||||
const $searchString = $option.find('.search-string');
|
this.$searchString = $option.find('.search-string');
|
||||||
$searchString.on('input', () => this.spacedUpdate.scheduleUpdate());
|
this.$searchString.on('input', () => this.spacedUpdate.scheduleUpdate());
|
||||||
|
|
||||||
utils.bindElShortcut($searchString, 'return', async () => {
|
utils.bindElShortcut(this.$searchString, 'return', async () => {
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
await this.spacedUpdate.updateNowIfNecessary();
|
||||||
|
|
||||||
this.refreshResults(); // FIXME!!!
|
this.triggerCommand('refreshResults');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.spacedUpdate = new SpacedUpdate(async () => {
|
this.spacedUpdate = new SpacedUpdate(async () => {
|
||||||
const searchString = $searchString.val();
|
const searchString = this.$searchString.val();
|
||||||
|
|
||||||
await this.setAttribute('label', 'searchString', searchString);
|
await this.setAttribute('label', 'searchString', searchString);
|
||||||
|
|
||||||
@ -62,8 +62,12 @@ export default class SearchString extends AbstractSearchOption {
|
|||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
$searchString.val(this.note.getLabelValue('searchString'));
|
this.$searchString.val(this.note.getLabelValue('searchString'));
|
||||||
|
|
||||||
return $option;
|
return $option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focusOnSearchDefinitionEvent() {
|
||||||
|
this.$searchString.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user