From 86bd471c1e737d6ad474cc767d18e3db4347bd20 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Thu, 16 Oct 2025 11:51:27 -0400 Subject: [PATCH 1/3] feat: implement working MultiEntry component This MultiEntry (Rewrite) is capable of storing and sending values through the server functions, as well as dynamically updating the master list as values are changed. --- src/common/form_schema.rs | 126 ++++++++++-- src/common/value_type.rs | 28 ++- src/components/multi_entry/mod.rs | 2 + src/components/multi_entry/multi_entry.rs | 4 +- .../multi_entry/multi_entry_member.rs | 4 +- src/components/multi_entry/rewrite.rs | 191 ++++++++++++++++++ src/components/row.rs | 15 ++ src/components/text_field.rs | 13 +- src/pages/home_page.rs | 18 +- 9 files changed, 369 insertions(+), 32 deletions(-) create mode 100644 src/components/multi_entry/rewrite.rs diff --git a/src/common/form_schema.rs b/src/common/form_schema.rs index 5ebd963..8655c94 100644 --- a/src/common/form_schema.rs +++ b/src/common/form_schema.rs @@ -1,18 +1,120 @@ +use std::collections::HashMap; +use leptos::{view, IntoView}; +use leptos::either::EitherOf5; +use leptos::prelude::RwSignal; use serde::{Serialize, Deserialize}; +use crate::components::{CheckboxList, OutlinedTextField, RadioList, Row, Select, ValueType}; /// Defines a series of options that allow a user to define a form. #[derive(Serialize, Deserialize, Clone, Debug)] pub enum InputType{ - /// Represents a text input. Requires a `String` key. The entered value will be returned as a - /// single `String` value. - Text, - /// Represents a number input. Requires a `String` key. The entered value will be returned as a - /// single `i32` value. - Number, - /// Represents a radio input. Requires a `String` key and a series of options. The selected - /// value will be returned as a single `String` value. - Radio(Vec), - /// Represents a checkbox input. Requires a `String` key and a series of options. The selected - /// value will be returned as a `Vec`. - Checkbox(Vec) + /// Represents a text input. Requires a `String` key, `String` label, and `String` placeholder. + /// The entered value will be returned as a single `String` value. + Text(String, String, String), + /// Represents a number input. Requires a `String` key, `String` label, and a `String` placeholder. + /// The entered value will be returned as a `String`, and will be parseable into any number type + /// (i.e. an `i32`, `i64`, etc) + Number(String, String, String), + /// Represents a radio input. Requires a `String` key, `String` label, and a series of `String` + /// options. The selected value will be returned as a `String`. + Radio(String, String, Vec), + /// Represents a checkbox input. Requires a `String` key, `String` label, and a series of `String` + /// options. The selected values will be returned as a `Vec`. + Checkbox(String, String, Vec), + /// Represents a dropdown input. Requires a `String` key, `String` label, and a series + /// of `String` options. The selected value will be returned as a `String`. + Select(String, String, Vec) +} + +impl InputType { + pub fn into_view(self, data_map: RwSignal>) -> impl IntoView { + view! { + {match self { + InputType::Text(member, label, placeholder) => + EitherOf5::A(view! { + + + + }), + InputType::Number(member, label, placeholder) => + EitherOf5::B(view! { + + }), + InputType::Checkbox(member, label, options) => + EitherOf5::C(view! { + + }), + InputType::Radio(member, label, options) => + EitherOf5::D(view! { + + }), + InputType::Select(member, label, options) => + EitherOf5::E(view! { +