Files
Trilium/apps/client/src/widgets/bulk_actions/note/rename_note.ts

62 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-06-12 23:29:11 +02:00
import SpacedUpdate from "../../../services/spaced_update.js";
import AbstractBulkAction from "../abstract_bulk_action.js";
import { t } from "../../../services/i18n.js";
2022-06-12 23:29:11 +02:00
const TPL = /*html*/`
2022-06-12 23:29:11 +02:00
<tr>
<td colspan="2">
<div style="display: flex; align-items: center">
<div style="margin-right: 10px; flex-shrink: 0;">${t("rename_note.rename_note_title_to")}</div>
<input type="text"
class="form-control new-title"
placeholder="${t("rename_note.new_note_title")}"
2025-01-09 18:07:02 +02:00
title="${t("rename_note.click_help_icon")}"/>
2022-06-12 23:29:11 +02:00
</div>
</td>
<td class="button-column">
<div class="dropdown help-dropdown">
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
2022-06-12 23:29:11 +02:00
<div class="dropdown-menu dropdown-menu-right p-4">
2025-01-09 18:07:02 +02:00
<p>${t("rename_note.evaluated_as_js_string")}</p>
2022-06-12 23:29:11 +02:00
<ul>
2025-01-09 18:07:02 +02:00
<li>${t("rename_note.example_note")}</li>
<li>${t("rename_note.example_new_title")}</li>
<li>${t("rename_note.example_date_prefix")}</li>
2022-06-12 23:29:11 +02:00
</ul>
2025-01-09 18:07:02 +02:00
${t("rename_note.api_docs")}
2022-06-12 23:29:11 +02:00
</div>
</div>
2022-06-12 23:29:11 +02:00
<span class="bx bx-x icon-action action-conf-del"></span>
</td>
</tr>`;
export default class RenameNoteBulkAction extends AbstractBulkAction {
2025-01-09 18:07:02 +02:00
static get actionName() {
return "renameNote";
}
static get actionTitle() {
return t("rename_note.rename_note");
}
2022-06-12 23:29:11 +02:00
doRender() {
const $action = $(TPL);
2025-01-09 18:07:02 +02:00
const $newTitle = $action.find(".new-title");
2022-06-12 23:29:11 +02:00
$newTitle.val(this.actionDef.newTitle || "");
const spacedUpdate = new SpacedUpdate(async () => {
await this.saveAction({
2025-01-09 18:07:02 +02:00
newTitle: $newTitle.val()
2022-06-12 23:29:11 +02:00
});
}, 1000);
2025-01-09 18:07:02 +02:00
$newTitle.on("input", () => spacedUpdate.scheduleUpdate());
2022-06-12 23:29:11 +02:00
return $action;
}
}