diff --git a/apps/client/src/widgets/bulk_actions/note/rename_note.ts b/apps/client/src/widgets/bulk_actions/note/rename_note.ts deleted file mode 100644 index 2fb4a05e1..000000000 --- a/apps/client/src/widgets/bulk_actions/note/rename_note.ts +++ /dev/null @@ -1,61 +0,0 @@ -import SpacedUpdate from "../../../services/spaced_update.js"; -import AbstractBulkAction from "../abstract_bulk_action.js"; -import { t } from "../../../services/i18n.js"; - -const TPL = /*html*/` - - -
-
${t("rename_note.rename_note_title_to")}
- - -
- - - - - - -`; - -export default class RenameNoteBulkAction extends AbstractBulkAction { - static get actionName() { - return "renameNote"; - } - static get actionTitle() { - return t("rename_note.rename_note"); - } - - doRender() { - const $action = $(TPL); - - const $newTitle = $action.find(".new-title"); - $newTitle.val(this.actionDef.newTitle || ""); - - const spacedUpdate = new SpacedUpdate(async () => { - await this.saveAction({ - newTitle: $newTitle.val() - }); - }, 1000); - - $newTitle.on("input", () => spacedUpdate.scheduleUpdate()); - - return $action; - } -} diff --git a/apps/client/src/widgets/bulk_actions/note/rename_note.tsx b/apps/client/src/widgets/bulk_actions/note/rename_note.tsx new file mode 100644 index 000000000..5fe9b8912 --- /dev/null +++ b/apps/client/src/widgets/bulk_actions/note/rename_note.tsx @@ -0,0 +1,53 @@ +import SpacedUpdate from "../../../services/spaced_update.js"; +import AbstractBulkAction, { ActionDefinition } from "../abstract_bulk_action.js"; +import { t } from "../../../services/i18n.js"; +import BulkAction from "../BulkAction.jsx"; +import FormTextBox from "../../react/FormTextBox.jsx"; +import { useEffect, useState } from "preact/hooks"; +import { useSpacedUpdate } from "../../react/hooks.jsx"; +import RawHtml from "../../react/RawHtml.jsx"; + +function RenameNoteBulkActionComponent({ bulkAction, actionDef }: { bulkAction: AbstractBulkAction, actionDef: ActionDefinition}) { + const [ newTitle, setNewTitle ] = useState(actionDef.newTitle ?? ""); + const spacedUpdate = useSpacedUpdate(() => bulkAction.saveAction({ newTitle })); + useEffect(() => spacedUpdate.scheduleUpdate(), [ newTitle ]); + + return ( + +

{t("rename_note.evaluated_as_js_string")}

+ + + + + } + > + +
+ ) +} + +export default class RenameNoteBulkAction extends AbstractBulkAction { + static get actionName() { + return "renameNote"; + } + + static get actionTitle() { + return t("rename_note.rename_note"); + } + + doRender() { + return + } + +}