diff --git a/src/common/expandable_info.rs b/src/common/expandable_info.rs
new file mode 100644
index 0000000..e7bafca
--- /dev/null
+++ b/src/common/expandable_info.rs
@@ -0,0 +1,34 @@
+use std::collections::HashMap;
+use serde::{Deserialize, Serialize};
+use macros::Reactive;
+use crate::components::ValueType;
+
+/// This struct allows for completely open-ended data storage.
+///
+/// The `HashMap` allows the application to store an arbitrary number of values which are accessible
+/// using a `String` as a key, allowing for simple shifting of stored values. All information is
+/// stored using the `ValueType` enum, which provides some simple methods to verify the type of the
+/// stored value. It *must* have a main key member name so that a database will know how to store
+/// the data.
+///
+/// In the future, this should also be optimized to store properly within a DynamoDB table. As of
+/// now, the table will simply create a single massive `Map` field that contains all the stored
+/// information in the `HashMap`. We'd prefer to be able to get single values if possible,
+/// especially for interoperability with other applications, should they be created.
+#[derive(Debug, Clone, Default, Serialize, Deserialize, Reactive)]
+pub struct ExpandableInfo {
+ /// The main key member. Required and used to get/put the information in a database.
+ key_member: String,
+ /// The main data store. Contains all information that this struct needs to hold.
+ #[serde(default)]
+ data: HashMap,
+}
+
+impl ExpandableInfo {
+ pub fn new(key: String) -> Self {
+ Self {
+ key_member: key,
+ data: HashMap::new(),
+ }
+ }
+}
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 8ca998f..0729aa3 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -1,5 +1,6 @@
mod student_info;
mod user;
mod form_schema;
+mod expandable_info;
-pub use self::{student_info::*, user::*, form_schema::*};
+pub use self::{student_info::*, user::*, form_schema::*, expandable_info::*};
diff --git a/src/common/student_info.rs b/src/common/student_info.rs
index ca617a4..6f7b792 100644
--- a/src/common/student_info.rs
+++ b/src/common/student_info.rs
@@ -46,5 +46,5 @@ pub struct StudentInfo {
}
fn default_number() -> ValueType {
- ValueType::Number(0)
+ ValueType::Number(None)
}
\ No newline at end of file
diff --git a/src/components/multi_entry/multi_entry.rs b/src/components/multi_entry/multi_entry.rs
index 1e85385..a1a49ff 100644
--- a/src/components/multi_entry/multi_entry.rs
+++ b/src/components/multi_entry/multi_entry.rs
@@ -14,6 +14,7 @@ fn render_entry_component(entry_data: MultiEntryData, member_info: MultiEntryMem
InputType::Text => view! {
@@ -92,11 +93,11 @@ pub fn MultiEntry(
let mut new_entry = MultiEntryData::new();
new_entry.data.insert(
name_member.get().member_name,
- ValueType::String(String::from("Testing")),
+ ValueType::String(Some(String::from("Testing"))),
);
new_entry.data.insert(
info_member.get().member_name,
- ValueType::String(new_entry.id.to_string()),
+ ValueType::String(Some(new_entry.id.to_string())),
);
entries.update(|entry_vec| entry_vec.push(new_entry));
};
diff --git a/src/components/multi_entry/value_type.rs b/src/components/multi_entry/value_type.rs
index 8b8d7fb..c482032 100644
--- a/src/components/multi_entry/value_type.rs
+++ b/src/components/multi_entry/value_type.rs
@@ -7,11 +7,11 @@ use std::fmt::Display;
#[derive(Clone, Serialize, Deserialize, Debug)]
pub enum ValueType {
/// Indicates a `String` value.
- String(String),
+ String(Option),
/// Indicates an `i32` value.
- Number(i32),
+ Number(Option),
/// Indicates a `Vec`, where `T` can be any other `ValueType`.
- List(Vec),
+ List(Option>),
}
impl ValueType {
@@ -21,11 +21,11 @@ impl ValueType {
}
/// Attempts to get this value as a `String` type. This is different from the `to_string` method.
- pub fn as_string(&self) -> Option {
+ pub fn as_string(&self) -> Result
+ // Each OutlinedTextField could be simplified later into an enum:
+ // Text { data_member, label, placeholder }, i.e.
+ // Text { "first_name", "First Name:", "John" }
@@ -180,6 +201,8 @@ pub fn HomePage() -> impl IntoView {
label="Contact Email:"
placeholder="student@region15.org"
disabled=elements_disabled
+ data_member = "contact_email"
+ data_map = expandable_react.data
value=reactive_info.contact_email
/>
@@ -188,6 +211,8 @@ pub fn HomePage() -> impl IntoView {
label="Phone Number:"
placeholder="123-456-7890"
disabled=elements_disabled
+ data_member = "phone_number"
+ data_map = expandable_react.data
value=reactive_info.phone_number
/>
@@ -196,10 +221,25 @@ pub fn HomePage() -> impl IntoView {
label="Street Address:"
placeholder="123 Fake Street"
disabled=elements_disabled
+ data_member = "address"
+ data_map = expandable_react.data
value=reactive_info.address
/>
+
+
+
//
+ // Each RadioList could be simplified into an enum:
+ // Radio { data_member, label, items }
// impl IntoView {
// />
//
//
+ // Select { data_member, label, items }
//