pub mod caching;
pub mod html_controls;
pub mod output_data;
pub mod validation;
#[derive(Default, serde::Serialize, serde::Deserialize, PartialEq, Clone, Debug)]
pub struct FileData {
#[serde(default)]
pub path: String,
#[serde(default)]
pub url: String,
#[serde(default)]
pub name: String,
#[serde(default, with = "mongodb::bson::compat::u2f")]
pub size: u32, }
#[derive(Default, serde::Serialize, serde::Deserialize, PartialEq, Clone, Debug)]
pub struct ImageData {
#[serde(default)]
pub path: String,
#[serde(default)]
pub url: String,
#[serde(default)]
pub name: String,
#[serde(default, with = "mongodb::bson::compat::u2f")]
pub size: u32, #[serde(default, with = "mongodb::bson::compat::u2f")]
pub width: u32, #[serde(default, with = "mongodb::bson::compat::u2f")]
pub height: u32, }
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Clone, Debug)]
pub struct Widget {
pub id: String, pub label: String,
pub widget: String,
pub input_type: String, pub name: String, pub value: String,
pub accept: String, pub placeholder: String,
pub pattern: String, pub minlength: usize,
pub maxlength: usize,
pub required: bool,
pub checked: bool, pub unique: bool,
pub disabled: bool,
pub readonly: bool,
pub step: String,
pub min: String,
pub max: String,
pub other_attrs: String, pub css_classes: String, pub options: Vec<(String, String)>, pub hint: String,
pub warning: String, pub error: String, pub common_msg: String, }
impl Default for Widget {
fn default() -> Self {
Widget {
id: String::new(),
label: String::new(),
widget: String::from("inputText"),
input_type: String::from("text"),
name: String::new(),
value: String::new(),
accept: String::new(),
placeholder: String::new(),
pattern: String::new(),
minlength: 0_usize,
maxlength: 256_usize,
required: false,
checked: false,
unique: false,
disabled: false,
readonly: false,
step: String::from("0"),
min: String::from("0"),
max: String::from("0"),
other_attrs: String::new(),
css_classes: String::new(),
options: Vec::new(),
hint: String::new(),
warning: String::new(),
error: String::new(),
common_msg: String::new(),
}
}
}
#[derive(serde::Deserialize)]
pub struct TransMapWidgets {
pub map_widgets: std::collections::HashMap<String, Widget>,
}
pub trait ToForm {
fn key() -> String;
fn form_name() -> String;
fn fields_name() -> Result<Vec<String>, Box<dyn std::error::Error>>;
fn widgets() -> Result<std::collections::HashMap<String, Widget>, Box<dyn std::error::Error>>;
fn self_to_json(&self) -> Result<serde_json::value::Value, Box<dyn std::error::Error>>;
}