summaryrefslogtreecommitdiff
path: root/src/viewmodel/organizational.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-02-09 22:38:40 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-02-09 22:38:40 +0100
commit9df3ff8d633a18e934d4e62b0e2e718620760552 (patch)
tree9d84d5fd3e418807905b3da928c1a2c3664b0272 /src/viewmodel/organizational.rs
parentad9ba30ed217ec9907d1faf389c321a1dcf5c13a (diff)
downloadwasm-card-9df3ff8d633a18e934d4e62b0e2e718620760552.tar.gz
wasm-card-9df3ff8d633a18e934d4e62b0e2e718620760552.tar.bz2
add file input field, include file as data url in vcard
Diffstat (limited to 'src/viewmodel/organizational.rs')
-rw-r--r--src/viewmodel/organizational.rs47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/viewmodel/organizational.rs b/src/viewmodel/organizational.rs
index e7a4ae7..c8f7164 100644
--- a/src/viewmodel/organizational.rs
+++ b/src/viewmodel/organizational.rs
@@ -4,7 +4,7 @@ use super::*;
#[derive(Clone,Debug,PartialEq)]
pub struct Organizational {
pub org: String,
- pub logo: String,
+ pub logo: Option<File>,
pub title: String,
pub role: String,
pub member: String,
@@ -15,7 +15,7 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational {
fn new() -> Self {
Self {
org: String::new(),
- logo: String::new(),
+ logo: None,
title: String::new(),
role: String::new(),
member: String::new(),
@@ -33,13 +33,44 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational {
value: self.org.clone(),
typ: typ.clone(),
},
- VCardPropertyInputField::Text{ // TODO: Add Upload for logo
+ VCardPropertyInputField::File{ // TODO: Add Upload for logo
label: "Logo".to_string(),
- id: Some("logo".to_string()),
- placeholder: None,
- oninput: link.callback(|e: InputData| Msg::UpdateLogo(e.value)),
+ 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)
+ ),
value: self.logo.clone(),
- typ: typ.clone(),
},
VCardPropertyInputField::Text{
label: "Title".to_string(),
@@ -77,7 +108,7 @@ impl VCardPropertyInputObject<OrganizationalView> for Organizational {
}
fn is_empty(&self) -> bool {
self.org.is_empty() &&
- self.logo.is_empty() &&
+ self.logo.is_none() &&
self.title.is_empty() &&
self.role.is_empty() &&
self.member.is_empty() &&