2025-08-09 18:45:06 +03:00
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
function MoveNoteBulkActionComponent({ bulkAction, actionDef }: { bulkAction: AbstractBulkAction, actionDef: ActionDefinition }) {
|
2025-08-09 19:49:32 +03:00
|
|
|
const [ targetParentNoteId, setTargetParentNoteId ] = useState<string>();
|
2025-08-09 18:45:06 +03:00
|
|
|
const spacedUpdate = useSpacedUpdate(() => {
|
2025-08-09 19:49:32 +03:00
|
|
|
return bulkAction.saveAction({ targetParentNoteId: targetParentNoteId })
|
2025-08-09 18:45:06 +03:00
|
|
|
});
|
2025-08-09 19:49:32 +03:00
|
|
|
useEffect(() => spacedUpdate.scheduleUpdate(), [ targetParentNoteId ]);
|
2025-08-09 18:45:06 +03:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<BulkAction
|
|
|
|
|
bulkAction={bulkAction}
|
|
|
|
|
label={t("move_note.move_note")}
|
|
|
|
|
helpText={<>
|
2025-08-10 14:07:54 +03:00
|
|
|
<p>{t("move_note.on_all_matched_notes")}:</p>
|
2025-08-09 18:45:06 +03:00
|
|
|
|
|
|
|
|
<ul style="margin-bottom: 0;">
|
2025-08-10 14:07:54 +03:00
|
|
|
<li>{t("move_note.move_note_new_parent")}</li>
|
|
|
|
|
<li>{t("move_note.clone_note_new_parent")}</li>
|
|
|
|
|
<li>{t("move_note.nothing_will_happen")}</li>
|
2025-08-09 18:45:06 +03:00
|
|
|
</ul>
|
|
|
|
|
</>}
|
|
|
|
|
>
|
|
|
|
|
<BulkActionText text={t("move_note.to")} />
|
|
|
|
|
|
|
|
|
|
<NoteAutocomplete
|
|
|
|
|
placeholder={t("move_note.target_parent_note")}
|
2025-08-09 19:49:32 +03:00
|
|
|
noteId={targetParentNoteId} noteIdChanged={setTargetParentNoteId}
|
2025-08-09 18:45:06 +03:00
|
|
|
/>
|
|
|
|
|
</BulkAction>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default class MoveNoteBulkAction extends AbstractBulkAction {
|
|
|
|
|
static get actionName() {
|
|
|
|
|
return "moveNote";
|
|
|
|
|
}
|
|
|
|
|
static get actionTitle() {
|
|
|
|
|
return t("move_note.move_note");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doRender() {
|
|
|
|
|
return <MoveNoteBulkActionComponent bulkAction={this} actionDef={this.actionDef} />
|
|
|
|
|
}
|
|
|
|
|
}
|