search definition refactoring

This commit is contained in:
zadam
2021-01-26 10:42:55 +01:00
parent 8b0a1e546d
commit 898c941333
7 changed files with 38 additions and 46 deletions

View File

@@ -200,28 +200,6 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
this.refresh();
});
this.$widget.on('click', '[data-search-option-del]', async event => {
async function deleteAttr(note, attrName) {
for (const attr of note.getOwnedAttributes()) {
if (attr.name === attrName) {
await server.remove(`notes/${note.noteId}/attributes/${attr.attributeId}`);
}
}
}
const searchOption = $(event.target).attr('data-search-option-del');
await deleteAttr(this.note, searchOption);
if (searchOption === 'orderBy') {
await deleteAttr(this.note, 'orderDirection');
}
await ws.waitForMaxKnownEntityChangeId();
this.refresh();
});
this.$widget.on('click', '[data-action-conf-del]', async event => {
const attributeId = $(event.target).closest('[data-attribute-id]').attr('data-attribute-id');
@@ -248,6 +226,10 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
this.triggerEvent('searchRefreshed', {tabId: this.tabContext.tabId});
}
async refreshSearchDefinitionCommand() {
await this.refresh();
}
async refreshWithNote(note) {
this.$component.show();