From 036a567bae8346eb38f9237f59645dbcc4f1cd8c Mon Sep 17 00:00:00 2001 From: jelemux Date: Tue, 9 Feb 2021 23:18:45 +0100 Subject: switch to cargo-make; format files with rustfmt --- src/viewmodel/organizational.rs | 71 ++++++++++++----------------------------- 1 file changed, 21 insertions(+), 50 deletions(-) (limited to 'src/viewmodel/organizational.rs') 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, @@ -22,10 +22,13 @@ impl VCardPropertyInputObject for Organizational { related: String::new(), } } - fn get_input_fields(&self, link: &yew::html::Scope) -> std::vec::Vec { + fn get_input_fields( + &self, + link: &yew::html::Scope, + ) -> std::vec::Vec { 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 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| - /* - 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| 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 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 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 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 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 +} -- cgit v1.2.3