pub mod generate_html;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Default, Serialize, 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, Serialize, Deserialize, PartialEq, Clone, Debug)]
pub struct ImageData {
#[serde(default)]
pub path: String, #[serde(default)]
pub path_xs: String,
#[serde(default)]
pub path_sm: String,
#[serde(default)]
pub path_md: String,
#[serde(default)]
pub path_lg: String,
#[serde(default)]
pub url: String, #[serde(default)]
pub url_xs: String,
#[serde(default)]
pub url_sm: String,
#[serde(default)]
pub url_md: String,
#[serde(default)]
pub url_lg: 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(Serialize, 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 options: Vec<(String, String)>, pub thumbnails: Vec<(String, u32)>, pub slug_sources: Vec<String>, pub is_hide: bool, pub other_attrs: String, pub css_classes: String, pub hint: String, pub warning: String, pub error: String, pub alert: 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("1"),
min: String::new(),
max: String::new(),
options: Vec::new(),
thumbnails: Vec::new(),
slug_sources: Vec::new(),
is_hide: false,
other_attrs: String::new(),
css_classes: String::new(),
hint: String::new(),
warning: String::new(),
error: String::new(),
alert: String::new(),
}
}
}
#[derive(Deserialize)]
pub struct TransMapWidgets {
pub map_widgets: HashMap<String, Widget>,
}
#[derive(Debug)]
pub enum HttpMethod {
GET,
POST,
}
impl Default for HttpMethod {
fn default() -> Self {
HttpMethod::GET
}
}
impl HttpMethod {
pub fn value(&self) -> String {
match self {
HttpMethod::GET => String::from("get"),
HttpMethod::POST => String::from("post"),
}
}
}
#[derive(Debug)]
pub enum Enctype {
Application,
Multipart,
Text,
}
impl Default for Enctype {
fn default() -> Self {
Enctype::Application
}
}
impl Enctype {
pub fn value(&self) -> String {
match self {
Enctype::Application => String::from("application/x-www-form-urlencoded"),
Enctype::Multipart => String::from("multipart/form-data"),
Enctype::Text => String::from("text/plain"),
}
}
}