diff --git a/apps/client/src/widgets/bulk_actions/note/move_note.ts b/apps/client/src/widgets/bulk_actions/note/move_note.ts deleted file mode 100644 index 9a75dbb53..000000000 --- a/apps/client/src/widgets/bulk_actions/note/move_note.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { t } from "../../../services/i18n.js"; -import SpacedUpdate from "../../../services/spaced_update.js"; -import AbstractBulkAction from "../abstract_bulk_action.js"; -import noteAutocompleteService from "../../../services/note_autocomplete.js"; - -const TPL = /*html*/` - - -
-
${t("move_note.move_note")}
- -
${t("move_note.to")}
- -
- -
-
- - - - - - -`; - -export default class MoveNoteBulkAction extends AbstractBulkAction { - static get actionName() { - return "moveNote"; - } - static get actionTitle() { - return t("move_note.move_note"); - } - - doRender() { - const $action = $(TPL); - - const $targetParentNote = $action.find(".target-parent-note"); - noteAutocompleteService.initNoteAutocomplete($targetParentNote); - $targetParentNote.setNote(this.actionDef.targetParentNoteId); - - $targetParentNote.on("autocomplete:closed", () => spacedUpdate.scheduleUpdate()); - - const spacedUpdate = new SpacedUpdate(async () => { - await this.saveAction({ - targetParentNoteId: $targetParentNote.getSelectedNoteId() - }); - }, 1000); - - $targetParentNote.on("input", () => spacedUpdate.scheduleUpdate()); - - return $action; - } -} diff --git a/apps/client/src/widgets/bulk_actions/note/move_note.tsx b/apps/client/src/widgets/bulk_actions/note/move_note.tsx new file mode 100644 index 000000000..677680bbc --- /dev/null +++ b/apps/client/src/widgets/bulk_actions/note/move_note.tsx @@ -0,0 +1,52 @@ +import { t } from "../../../services/i18n.js"; +import AbstractBulkAction, { ActionDefinition } from "../abstract_bulk_action.js"; +import BulkAction, { BulkActionText } from "../BulkAction.jsx"; +import NoteAutocomplete from "../../react/NoteAutocomplete.jsx"; +import { useEffect, useState } from "preact/hooks"; +import { useSpacedUpdate } from "../../react/hooks.jsx"; +import { Suggestion } from "../../../services/note_autocomplete.js"; + +function MoveNoteBulkActionComponent({ bulkAction, actionDef }: { bulkAction: AbstractBulkAction, actionDef: ActionDefinition }) { + const [ suggestion, setSuggestion ] = useState(); + const spacedUpdate = useSpacedUpdate(() => { + const noteId = suggestion?.notePath?.split("/")?.at(-1); + return bulkAction.saveAction({ targetParentNoteId: noteId }) + }); + useEffect(() => spacedUpdate.scheduleUpdate(), [ suggestion ]); + + return ( + +

${t("move_note.on_all_matched_notes")}:

+ + + } + > + + + +
+ ) +} + +export default class MoveNoteBulkAction extends AbstractBulkAction { + static get actionName() { + return "moveNote"; + } + static get actionTitle() { + return t("move_note.move_note"); + } + + doRender() { + return + } +}