mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(react/bulk_actions): clean up
This commit is contained in:
parent
7c79fbefa6
commit
899f85f4e7
@ -1,7 +1,5 @@
|
||||
import { t } from "../../services/i18n.js";
|
||||
import server from "../../services/server.js";
|
||||
import ws from "../../services/ws.js";
|
||||
import utils from "../../services/utils.js";
|
||||
import type FAttribute from "../../entities/fattribute.js";
|
||||
import { VNode } from "preact";
|
||||
|
||||
@ -28,29 +26,9 @@ export default abstract class AbstractBulkAction {
|
||||
this.actionDef = actionDef;
|
||||
}
|
||||
|
||||
render() {
|
||||
try {
|
||||
const $rendered = this.doRender();
|
||||
if (Array.isArray($rendered)) {
|
||||
$rendered
|
||||
.find(".action-conf-del")
|
||||
.on("click", () => this.deleteAction())
|
||||
.attr("title", t("abstract_bulk_action.remove_this_search_action"));
|
||||
|
||||
utils.initHelpDropdown($rendered);
|
||||
|
||||
return $rendered;
|
||||
} else {
|
||||
return $rendered;
|
||||
}
|
||||
} catch (e: any) {
|
||||
logError(`Failed rendering search action: ${JSON.stringify(this.attribute.dto)} with error: ${e.message} ${e.stack}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// to be overridden
|
||||
abstract doRender(): JQuery<HTMLElement> | VNode;
|
||||
abstract doRender(): VNode;
|
||||
|
||||
static get actionName() {
|
||||
return "";
|
||||
}
|
||||
@ -70,9 +48,6 @@ export default abstract class AbstractBulkAction {
|
||||
|
||||
async deleteAction() {
|
||||
await server.remove(`notes/${this.attribute.noteId}/attributes/${this.attribute.attributeId}`);
|
||||
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
|
||||
//await this.triggerCommand('refreshSearchDefinition');
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ function ExistingActionsList({ existingActions }: { existingActions?: RenameNote
|
||||
<table class="bulk-existing-action-list">
|
||||
{ existingActions
|
||||
? existingActions
|
||||
.map(action => action.render())
|
||||
.map(action => action.doRender())
|
||||
.filter(renderedAction => renderedAction !== null)
|
||||
: <p>{t("bulk_actions.none_yet")}</p>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user