diff options
Diffstat (limited to 'src/viewmodel/organizational.rs')
-rw-r--r-- | src/viewmodel/organizational.rs | 71 |
1 files changed, 21 insertions, 50 deletions
diff --git a/src/viewmodel/organizational.rs b/src/viewmodel/organizational.rs index c8f7164..72b19d2 100644 --- a/src/viewmodel/organizational.rs +++ b/src/viewmodel/organizational.rs @@ -1,7 +1,7 @@ -use crate::view::organizational::*; use super::*; +use crate::view::organizational::*; -#[derive(Clone,Debug,PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub struct Organizational { pub org: String, pub logo: Option<File>, @@ -22,10 +22,13 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational { related: String::new(), } } - fn get_input_fields(&self, link: &yew::html::Scope<OrganizationalView>) -> std::vec::Vec<VCardPropertyInputField> { + fn get_input_fields( + &self, + link: &yew::html::Scope<OrganizationalView>, + ) -> std::vec::Vec<VCardPropertyInputField> { let typ = String::from("text"); vec![ - VCardPropertyInputField::Text{ + VCardPropertyInputField::Text { label: "Organisation".to_string(), id: Some("org".to_string()), placeholder: None, @@ -33,46 +36,14 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational { value: self.org.clone(), typ: typ.clone(), }, - VCardPropertyInputField::File{ // TODO: Add Upload for logo + VCardPropertyInputField::File { + // TODO: Add Upload for logo label: "Logo".to_string(), name: "logo".to_string(), - callback: link.callback(|file: Option<File>| - /* - if let ChangeData::Files(files) = c { - match files.item(0) { - Some(file) => { - let filereader = match FileReaderSync::new() { - Ok(reader) => reader, - Err(_) => { - ConsoleService::warn("Couldn't create new filereader."); - return Msg::UpdateLogo(None) - }, - }; - let content = match filereader.read_as_data_url(&file) { - Ok(content) => content, - Err(_) => { - ConsoleService::warn("Error: Couldn't get file as data url."); - return Msg::UpdateLogo(None) - }, - }; - Msg::UpdateLogo( - Some(File { - name: file.name(), - content, - }) - ) - }, - None => Msg::UpdateLogo(None), - } - } else { - Msg::UpdateLogo(None) - } - */ - Msg::UpdateLogo(file) - ), + callback: link.callback(|file: Option<File>| Msg::UpdateLogo(file)), value: self.logo.clone(), }, - VCardPropertyInputField::Text{ + VCardPropertyInputField::Text { label: "Title".to_string(), id: Some("title".to_string()), placeholder: None, @@ -80,7 +51,7 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational { value: self.title.clone(), typ: typ.clone(), }, - VCardPropertyInputField::Text{ + VCardPropertyInputField::Text { label: "Role".to_string(), id: Some("role".to_string()), placeholder: None, @@ -88,7 +59,7 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational { value: self.role.clone(), typ: typ.clone(), }, - VCardPropertyInputField::Text{ + VCardPropertyInputField::Text { label: "Member".to_string(), id: Some("member".to_string()), placeholder: None, @@ -96,7 +67,7 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational { value: self.member.clone(), typ: typ.clone(), }, - VCardPropertyInputField::Text{ + VCardPropertyInputField::Text { label: "Related".to_string(), id: Some("related".to_string()), placeholder: None, @@ -107,11 +78,11 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational { ] } fn is_empty(&self) -> bool { - self.org.is_empty() && - self.logo.is_none() && - self.title.is_empty() && - self.role.is_empty() && - self.member.is_empty() && - self.related.is_empty() + self.org.is_empty() + && self.logo.is_none() + && self.title.is_empty() + && self.role.is_empty() + && self.member.is_empty() + && self.related.is_empty() } -}
\ No newline at end of file +} |