From 318185bd4abf3cb34c5dce1b34712372085bcc1b Mon Sep 17 00:00:00 2001 From: Fritz Heiden Date: Thu, 10 Apr 2025 20:02:10 +0200 Subject: [PATCH] feat: change objects to instances passed to remotes service --- www/src/components/validated-text-input.jsx | 9 +++++- www/src/modals/create-command-modal.jsx | 32 ++++++++++----------- www/src/modals/create-remote-modal.jsx | 11 ++++--- www/src/services/remotes-service.js | 6 ++-- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/www/src/components/validated-text-input.jsx b/www/src/components/validated-text-input.jsx index c92e67d..d163b3c 100644 --- a/www/src/components/validated-text-input.jsx +++ b/www/src/components/validated-text-input.jsx @@ -2,7 +2,13 @@ import { createSignal, mergeProps } from "solid-js"; function ValidatedTextInput(props) { props = mergeProps( - { type: "text", valid: true, onInput: () => {}, errorText: "" }, + { + type: "text", + valid: true, + onInput: () => {}, + errorText: "", + placeholder: "", + }, props ); let [isActive, setActive] = createSignal(false); @@ -15,6 +21,7 @@ function ValidatedTextInput(props) { } id={props.id} value={props.value} + placeholder={props.placeholder} onInput={props.onInput} onFocusOut={() => setActive(true)} /> diff --git a/www/src/modals/create-command-modal.jsx b/www/src/modals/create-command-modal.jsx index 288ee49..dd15e0a 100644 --- a/www/src/modals/create-command-modal.jsx +++ b/www/src/modals/create-command-modal.jsx @@ -26,14 +26,6 @@ function CreateCommandModal(props) { const isCommandTypeValid = createMemo(() => commandType() !== ""); const isTitleValid = createMemo(() => title().length >= MIN_TITLE_LENGTH); - createEffect(() => { - let commandString = commandType() - ? Command.CommandTypes[commandType()] - : ""; - let protocolString = protocol() ? Command.Protocols[protocol()] : ""; - setTitle(commandString + " " + protocolString); - }); - const isFormValid = createMemo( () => isProtocolValid() && @@ -46,13 +38,15 @@ function CreateCommandModal(props) { async function handleCreateCommand() { let command; try { - command = await RemotesService.createCommand({ - protocol: protocol(), - commandNumber: commandNumber(), - device: device(), - commandType: commandType(), - title: title(), - }); + command = await RemotesService.createCommand( + new Command({ + protocol: protocol(), + commandNumber: commandNumber(), + device: device(), + commandType: commandType(), + title: title(), + }) + ); } catch (e) { setError(e.message); return; @@ -93,7 +87,9 @@ function CreateCommandModal(props) { class="form-select" onChange={(e) => setProtocol(e.target.value)} > - + {Object.keys(Command.Protocols).map((protocol) => ( ))} @@ -138,7 +134,9 @@ function CreateCommandModal(props) { class="form-select" onChange={(e) => setCommandType(e.target.value)} > - + {Object.keys(Command.CommandTypes).map((commandType) => (