summaryrefslogtreecommitdiff
path: root/src/view/input_objects/mod.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2020-11-25 10:31:04 +0100
committerjelemux <jeremias.weber@protonmail.com>2020-11-25 10:31:04 +0100
commitb1ba906491a1ed396d47b0751f080fef991ea344 (patch)
treec8e306c217dbdc352e66000822d8fc7e4cdc55fb /src/view/input_objects/mod.rs
parent5a03734b6767fed04c0913384584d8f59dc597ea (diff)
downloadwasm-card-b1ba906491a1ed396d47b0751f080fef991ea344.tar.gz
wasm-card-b1ba906491a1ed396d47b0751f080fef991ea344.tar.bz2
Struktur umbauen
Diffstat (limited to 'src/view/input_objects/mod.rs')
-rw-r--r--src/view/input_objects/mod.rs106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/view/input_objects/mod.rs b/src/view/input_objects/mod.rs
deleted file mode 100644
index 7c0fdff..0000000
--- a/src/view/input_objects/mod.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-use vcard::properties;
-use yew::prelude::*;
-use super::VCardPropertyInputComponent;
-
-pub mod address;
-pub mod birthday;
-pub mod name;
-pub mod photo;
-pub mod telephone;
-pub mod utility;
-
-pub trait VCardPropertyInputObject<P: properties::Property, C: VCardPropertyInputComponent<P, Self>>
- where Self: Sized
-{
- fn new() -> Self;
- fn get_input_fields(&self, link: &ComponentLink<C>) -> Vec<VCardPropertyInputField>;
- fn render(&self, link: &ComponentLink<C>) -> Html {
- html!{
- <div class="columns is-mobile is-multiline">
- {
- for self.get_input_fields(link).iter().map(|field|
- field.render()
- )
- }
- </div>
- }
- }
- fn to_vcard_property(&self) -> Result<P, VCardPropertyInputError>;
-}
-
-#[derive(Debug)]
-pub struct VCardPropertyInputError {
- msg: String,
-}
-
-pub enum VCardPropertyInputField {
- Text {
- label: String,
- id: Option<String>,
- placeholder: Option<String>,
- oninput: Callback<InputData>,
- value: String,
- },
- CheckBox {
- label: String,
- id: Option<String>,
- onclick: Callback<MouseEvent>,
- value: bool,
- },
-}
-
-impl VCardPropertyInputField {
- pub fn render(&self) -> Html {
- match self {
- Self::Text {
- label,
- id,
- placeholder,
- oninput,
- value: _,
- } => Self::text_field_input(label, id, placeholder, oninput),
- Self::CheckBox {
- label,
- id,
- onclick,
- value,
- } => Self::checkbox_field_input(label, id, value, onclick),
- }
- }
- fn text_field_input(label: &str, id: &Option<String>, placeholder: &Option<String>, oninput: &Callback<InputData>) -> Html {
- html!{
- <div class="field column
- is-one-fifth-widescreen
- is-one-quarter-desktop
- is-one-third-tablet
- is-half-mobile" >
- <label class="label">{ label }</label>
- <div class="control">
- <input id=id.as_ref().unwrap_or(&"".to_string())
- type="text"
- placeholder=placeholder.as_ref().unwrap_or(&"".to_string())
- oninput=oninput
- />
- </div>
- </div>
- }
- }
- fn checkbox_field_input(label: &str, id: &Option<String>, checked: &bool, onclick: &Callback<MouseEvent>) -> Html {
- html!{
- <div class="field column
- is-one-fifth-widescreen
- is-one-quarter-desktop
- is-one-third-tablet
- is-half-mobile" >
- <label class="checkbox">
- <input id=id.as_ref().unwrap_or(&"".to_string())
- type="checkbox"
- checked=*checked
- onclick=onclick
- />
- { label }
- </label>
- </div>
- }
- }
-} \ No newline at end of file