diff options
author | jelemux <jeremias.weber@protonmail.com> | 2021-02-17 19:43:30 +0100 |
---|---|---|
committer | jelemux <jeremias.weber@protonmail.com> | 2021-02-17 19:43:30 +0100 |
commit | d0d42c5ae00560e4464479a98df90ed063a1c773 (patch) | |
tree | 09ffff29b239768422bd3a9e147b75a3b3866a13 /src/model/mod.rs | |
parent | cb310a66e94db4e0c4f7d0373a670156b012412a (diff) | |
download | wasm-card-d0d42c5ae00560e4464479a98df90ed063a1c773.tar.gz wasm-card-d0d42c5ae00560e4464479a98df90ed063a1c773.tar.bz2 |
change dates to other_identification and add some stuff
Diffstat (limited to 'src/model/mod.rs')
-rw-r--r-- | src/model/mod.rs | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/src/model/mod.rs b/src/model/mod.rs index 45c91f1..b8dcfff 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -7,23 +7,23 @@ use yew::prelude::*; use yew::services::ConsoleService; pub mod address; -pub mod dates; pub mod name; pub mod organizational; +pub mod other_identification; pub mod telephone; pub mod utility; pub mod vcard; /// Trait for types that represent the data of a vcard property used inside of a `VCardPropertyInputComponent`. -pub trait VCardPropertyInputObject<M: 'static + PartialEq + Clone>: Clone + PartialEq +pub trait VCardPropertyInputGroupObject<M: 'static + PartialEq + Clone>: Clone + PartialEq where Self: Sized, { - /// Function for creating a new (and empty) `VCardPropertyInputObject`. + /// Function for creating a new (and empty) `VCardPropertyInputGroupObject`. fn new() -> Self; /// Getter function for the title of the component fn get_title(&self) -> String; - /// Converts each field of the `VCardPropertyInputObject` to a VCardPropertyInputField and returns them as a vector. + /// Converts each field of the `VCardPropertyInputGroupObject` to a VCardPropertyInputField and returns them as a vector. fn get_input_fields( &self, link: &ComponentLink<PropertyGroupInputComponent<Self, M>>, @@ -33,7 +33,7 @@ where props: InputProps<Self, M>, msg: <PropertyGroupInputComponent<Self, M> as yew::Component>::Message, ) -> bool; - /// Returns a `Html` representation of the `VCardPropertyInputObject`. + /// Returns a `Html` representation of the `VCardPropertyInputGroupObject`. fn render(&self, link: &ComponentLink<PropertyGroupInputComponent<Self, M>>) -> Html { html! { <div class="columns is-mobile is-multiline"> @@ -45,7 +45,7 @@ where </div> } } - /// Convenience function for checking if the `VCardPropertyInputObject` is empty. + /// Convenience function for checking if the `VCardPropertyInputGroupObject` is empty. fn is_empty(&self) -> bool; } @@ -73,6 +73,13 @@ pub enum VCardPropertyInputField { callback: Callback<Option<File>>, value: Option<File>, }, + Select { + label: String, + id: Option<String>, + options: Vec<(String, String)>, + onchange: Callback<ChangeData>, + value: String, + }, CheckBox { label: String, id: Option<String>, @@ -99,6 +106,13 @@ impl VCardPropertyInputField { callback, value, } => Self::file_field_input(label, name, callback, value), + Self::Select { + label, + id, + options, + onchange, + value, + } => Self::select_field_input(label, id, options, onchange, value), Self::CheckBox { label, id, @@ -180,10 +194,10 @@ impl VCardPropertyInputField { }); html! { <div class="field column - is-one-fifth-widescreen - is-one-quarter-desktop - is-one-third-tablet - is-half-mobile" > + is-one-third-widescreen + is-two-quarters-desktop + is-two-thirds-tablet + is-full-mobile" > <label class="label">{ label }</label> <div class="file has-name control"> <label class="file-label"> @@ -213,6 +227,37 @@ impl VCardPropertyInputField { </div> } } + fn select_field_input( + label: &str, + id: &Option<String>, + options: &Vec<(String, String)>, + onchange: &Callback<ChangeData>, + value: &str, + ) -> 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="select"> + <select id=id.as_ref().unwrap_or(&"".to_string()) + value=value + onchange=onchange > + { + for options.iter().map(|option| + html! { + <option value=option.0>{ option.1.clone() }</option> + } + ) + } + </select> + </div> + + </div> + } + } /// Returns an `Html` representation of a checkbox input field with the given parameters. fn checkbox_field_input( label: &str, |