diff --git a/apps/client/src/widgets/bulk_actions/relation/add_relation.ts b/apps/client/src/widgets/bulk_actions/relation/add_relation.ts
deleted file mode 100644
index 165162d85..000000000
--- a/apps/client/src/widgets/bulk_actions/relation/add_relation.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import SpacedUpdate from "../../../services/spaced_update.js";
-import AbstractBulkAction from "../abstract_bulk_action.js";
-import noteAutocompleteService from "../../../services/note_autocomplete.js";
-import { t } from "../../../services/i18n.js";
-
-const TPL = /*html*/`
-
-
-
- ${t("add_relation.add_relation")}
-
-
-
- ${t("add_relation.to")}
-
-
-
-
-
- |
-
-
-
-
-
-
-
- |
-
`;
-
-export default class AddRelationBulkAction extends AbstractBulkAction {
- static get actionName() {
- return "addRelation";
- }
- static get actionTitle() {
- return t("add_relation.add_relation");
- }
-
- doRender() {
- const $action = $(TPL);
-
- const $relationName = $action.find(".relation-name");
- $relationName.val(this.actionDef.relationName || "");
-
- const $targetNote = $action.find(".target-note");
- noteAutocompleteService.initNoteAutocomplete($targetNote);
- $targetNote.setNote(this.actionDef.targetNoteId);
-
- $targetNote.on("autocomplete:closed", () => spacedUpdate.scheduleUpdate());
-
- const spacedUpdate = new SpacedUpdate(async () => {
- await this.saveAction({
- relationName: $relationName.val(),
- targetNoteId: $targetNote.getSelectedNoteId()
- });
- }, 1000);
-
- $relationName.on("input", () => spacedUpdate.scheduleUpdate());
- $targetNote.on("input", () => spacedUpdate.scheduleUpdate());
-
- return $action;
- }
-}
diff --git a/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx b/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx
new file mode 100644
index 000000000..927c10ace
--- /dev/null
+++ b/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx
@@ -0,0 +1,52 @@
+import SpacedUpdate from "../../../services/spaced_update.js";
+import AbstractBulkAction, { ActionDefinition } from "../abstract_bulk_action.js";
+import noteAutocompleteService from "../../../services/note_autocomplete.js";
+import { t } from "../../../services/i18n.js";
+import BulkAction, { BulkActionText } from "../BulkAction.jsx";
+import NoteAutocomplete from "../../react/NoteAutocomplete.jsx";
+import FormTextBox from "../../react/FormTextBox.jsx";
+import { useEffect, useState } from "preact/hooks";
+import { useSpacedUpdate } from "../../react/hooks.jsx";
+
+function AddRelationBulkActionComponent({ bulkAction, actionDef }: { bulkAction: AbstractBulkAction, actionDef: ActionDefinition }) {
+ const [ relationName, setRelationName ] = useState(actionDef.relationName);
+ const [ targetNoteId, setTargetNoteId ] = useState(actionDef.targetNoteId);
+ const spacedUpdate = useSpacedUpdate(() => bulkAction.saveAction({ relationName, targetNoteId }));
+ useEffect(() => spacedUpdate.scheduleUpdate(), [ relationName, targetNoteId ]);
+
+ return (
+
+
+
+
+
+
+
+ )
+}
+
+export default class AddRelationBulkAction extends AbstractBulkAction {
+
+ static get actionName() {
+ return "addRelation";
+ }
+ static get actionTitle() {
+ return t("add_relation.add_relation");
+ }
+
+ doRender() {
+ return
+ }
+}
diff --git a/apps/client/src/widgets/react/FormTextBox.tsx b/apps/client/src/widgets/react/FormTextBox.tsx
index e06004fb5..476825d96 100644
--- a/apps/client/src/widgets/react/FormTextBox.tsx
+++ b/apps/client/src/widgets/react/FormTextBox.tsx
@@ -1,13 +1,13 @@
import { InputHTMLAttributes, RefObject } from "preact/compat";
-interface FormTextBoxProps extends Pick, "placeholder" | "autoComplete" | "className" | "type" | "name" | "pattern" | "title"> {
+interface FormTextBoxProps extends Pick, "placeholder" | "autoComplete" | "className" | "type" | "name" | "pattern" | "title" | "style"> {
id?: string;
currentValue?: string;
onChange?(newValue: string): void;
inputRef?: RefObject;
}
-export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete, inputRef, placeholder, title, pattern }: FormTextBoxProps) {
+export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete, inputRef, placeholder, title, pattern, style }: FormTextBoxProps) {
return (
onChange?.(e.currentTarget.value)} />
+ onInput={e => onChange?.(e.currentTarget.value)}
+ style={style}
+ />
);
}
\ No newline at end of file