use yew::prelude::*; use crate::view::VCardPropertyInputComponent; pub mod vcard; pub mod address; pub mod name; pub mod telephone; pub mod utility; pub trait VCardPropertyInputObject> where Self: Sized { fn new() -> Self; fn get_input_fields(&self, link: &ComponentLink) -> Vec; fn render(&self, link: &ComponentLink) -> Html { html!{
{ for self.get_input_fields(link).iter().map(|field| field.render() ) }
} } fn is_empty(&self) -> bool; } #[derive(Debug,Clone,PartialEq)] pub struct Error { pub msg: String, } pub enum VCardPropertyInputField { Text { label: String, id: Option, placeholder: Option, oninput: Callback, value: String, }, CheckBox { label: String, id: Option, onclick: Callback, 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, placeholder: &Option, oninput: &Callback) -> Html { html!{
} } fn checkbox_field_input(label: &str, id: &Option, checked: &bool, onclick: &Callback) -> Html { html!{
} } }