1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
use crate::view::organizational::*;
use super::*;
#[derive(Clone,Debug,PartialEq)]
pub struct Organizational {
pub org: String,
pub logo: Option<File>,
pub title: String,
pub role: String,
pub member: String,
pub related: String,
}
impl VCardPropertyInputObject<OrganizationalView> for Organizational {
fn new() -> Self {
Self {
org: String::new(),
logo: None,
title: String::new(),
role: String::new(),
member: String::new(),
related: String::new(),
}
}
fn get_input_fields(&self, link: &yew::html::Scope<OrganizationalView>) -> std::vec::Vec<VCardPropertyInputField> {
let typ = String::from("text");
vec![
VCardPropertyInputField::Text{
label: "Organisation".to_string(),
id: Some("org".to_string()),
placeholder: None,
oninput: link.callback(|e: InputData| Msg::UpdateOrg(e.value)),
value: self.org.clone(),
typ: typ.clone(),
},
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)
),
value: self.logo.clone(),
},
VCardPropertyInputField::Text{
label: "Title".to_string(),
id: Some("title".to_string()),
placeholder: None,
oninput: link.callback(|e: InputData| Msg::UpdateTitle(e.value)),
value: self.title.clone(),
typ: typ.clone(),
},
VCardPropertyInputField::Text{
label: "Role".to_string(),
id: Some("role".to_string()),
placeholder: None,
oninput: link.callback(|e: InputData| Msg::UpdateRole(e.value)),
value: self.role.clone(),
typ: typ.clone(),
},
VCardPropertyInputField::Text{
label: "Member".to_string(),
id: Some("member".to_string()),
placeholder: None,
oninput: link.callback(|e: InputData| Msg::UpdateMember(e.value)),
value: self.member.clone(),
typ: typ.clone(),
},
VCardPropertyInputField::Text{
label: "Related".to_string(),
id: Some("related".to_string()),
placeholder: None,
oninput: link.callback(|e: InputData| Msg::UpdateRelated(e.value)),
value: self.related.clone(),
typ: typ,
},
]
}
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()
}
}
|