search definition action refactoring

This commit is contained in:
zadam 2021-01-26 10:48:28 +01:00
parent 898c941333
commit 87925f72a3
12 changed files with 21 additions and 23 deletions

6
package-lock.json generated
View file

@ -2634,9 +2634,9 @@
}
},
"electron": {
"version": "11.2.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-11.2.1.tgz",
"integrity": "sha512-Im1y29Bnil+Nzs+FCTq01J1OtLbs+2ZGLLllaqX/9n5GgpdtDmZhS/++JHBsYZ+4+0n7asO+JKQgJD+CqPClzg==",
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-9.4.1.tgz",
"integrity": "sha512-r4CxoVG9Ja7tBtkilWMnBsBGup8G8Z+v7icZmwysHa8/OSr0OrLjrcOF/30BAP7yPE5fz/XTxygnltzW4OTZdw==",
"dev": true,
"requires": {
"@electron/get": "^1.0.1",

View file

@ -77,7 +77,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "11.2.1",
"electron": "9.4.1",
"electron-builder": "22.9.1",
"electron-packager": "15.2.0",
"electron-rebuild": "2.3.4",

View file

@ -14,7 +14,7 @@ export default class AbstractSearchAction extends Component {
try {
const $rendered = this.doRender();
$rendered.attr('data-attribute-id', this.attribute.attributeId);
$rendered.find('.action-conf-del').on('click', () => this.deleteAction())
return $rendered;
}
@ -39,4 +39,12 @@ export default class AbstractSearchAction extends Component {
await ws.waitForMaxKnownEntityChangeId();
}
async deleteAction() {
await server.remove(`notes/${this.attribute.noteId}/attributes/${this.attribute.attributeId}`);
await ws.waitForMaxKnownEntityChangeId();
await this.triggerCommand('refreshSearchDefinition');
}
}

View file

@ -17,7 +17,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -8,7 +8,7 @@ const TPL = `
Delete matched note
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -17,7 +17,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -16,7 +16,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -28,7 +28,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -28,7 +28,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -24,7 +24,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -24,7 +24,7 @@ const TPL = `
</div>
</td>
<td>
<span class="bx bx-x icon-action" data-action-conf-del></span>
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;

View file

@ -200,16 +200,6 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
this.refresh();
});
this.$widget.on('click', '[data-action-conf-del]', async event => {
const attributeId = $(event.target).closest('[data-attribute-id]').attr('data-attribute-id');
await server.remove(`notes/${this.noteId}/attributes/${attributeId}`);
await ws.waitForMaxKnownEntityChangeId();
this.refresh();
});
this.$searchOptions = this.$widget.find('.search-options');
this.$actionOptions = this.$widget.find('.action-options');