feat: update text field to use open-ended structures

This commit is contained in:
alphafetus committed 2025-09-25 09:29:04 -04:00
1 parent 6512f5fe13
commit 7a453ad367
8 files changed
+166 -47

No files matched your search

+34
View File
@@ -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<String, ValueType>,
}
impl ExpandableInfo {
pub fn new(key: String) -> Self {
Self {
key_member: key,
data: HashMap::new(),
}
}
}
+2 -1
View File
@@ -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::*};
+1 -1
View File
@@ -46,5 +46,5 @@ pub struct StudentInfo {
}
fn default_number() -> ValueType {
ValueType::Number(0)
ValueType::Number(None)
}