mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +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 server from "../../services/server.js";
|
||||||
import ws from "../../services/ws.js";
|
import ws from "../../services/ws.js";
|
||||||
import utils from "../../services/utils.js";
|
|
||||||
import type FAttribute from "../../entities/fattribute.js";
|
import type FAttribute from "../../entities/fattribute.js";
|
||||||
import { VNode } from "preact";
|
import { VNode } from "preact";
|
||||||
|
|
||||||
@ -28,29 +26,9 @@ export default abstract class AbstractBulkAction {
|
|||||||
this.actionDef = actionDef;
|
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
|
// to be overridden
|
||||||
abstract doRender(): JQuery<HTMLElement> | VNode;
|
abstract doRender(): VNode;
|
||||||
|
|
||||||
static get actionName() {
|
static get actionName() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -70,9 +48,6 @@ export default abstract class AbstractBulkAction {
|
|||||||
|
|
||||||
async deleteAction() {
|
async deleteAction() {
|
||||||
await server.remove(`notes/${this.attribute.noteId}/attributes/${this.attribute.attributeId}`);
|
await server.remove(`notes/${this.attribute.noteId}/attributes/${this.attribute.attributeId}`);
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
//await this.triggerCommand('refreshSearchDefinition');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ function ExistingActionsList({ existingActions }: { existingActions?: RenameNote
|
|||||||
<table class="bulk-existing-action-list">
|
<table class="bulk-existing-action-list">
|
||||||
{ existingActions
|
{ existingActions
|
||||||
? existingActions
|
? existingActions
|
||||||
.map(action => action.render())
|
.map(action => action.doRender())
|
||||||
.filter(renderedAction => renderedAction !== null)
|
.filter(renderedAction => renderedAction !== null)
|
||||||
: <p>{t("bulk_actions.none_yet")}</p>
|
: <p>{t("bulk_actions.none_yet")}</p>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user