summaryrefslogtreecommitdiff
path: root/src/viewmodel/dates.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-02-05 18:05:16 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-02-05 18:05:16 +0100
commitfd5b054fe655c81533c8a1138ba55a82a7b9d085 (patch)
tree2d90466a05356490ed3d15fa19e8dc0fe763499e /src/viewmodel/dates.rs
parent87007b8785be959ca7687e2bec7401514e92581d (diff)
downloadwasm-card-fd5b054fe655c81533c8a1138ba55a82a7b9d085.tar.gz
wasm-card-fd5b054fe655c81533c8a1138ba55a82a7b9d085.tar.bz2
add date properties
Diffstat (limited to 'src/viewmodel/dates.rs')
-rw-r--r--src/viewmodel/dates.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/viewmodel/dates.rs b/src/viewmodel/dates.rs
new file mode 100644
index 0000000..6c7fa37
--- /dev/null
+++ b/src/viewmodel/dates.rs
@@ -0,0 +1,43 @@
+use crate::view::dates::*;
+use super::*;
+
+/// Type that represents the vcard `anniversary` and `birthday` properties.
+#[derive(Clone, Debug)]
+pub struct Dates {
+ pub anniversary: String,
+ pub birthday: String,
+}
+
+impl VCardPropertyInputObject<DatesView> for Dates {
+ fn new() -> Self {
+ Self {
+ anniversary: String::new(),
+ birthday: String::new(),
+ }
+ }
+ fn get_input_fields(&self, link: &yew::html::Scope<DatesView>) -> std::vec::Vec<VCardPropertyInputField> {
+ let typ = String::from("date");
+ vec![
+ VCardPropertyInputField::Text{
+ label: "Anniversary".to_string(),
+ id: Some("anniversary".to_string()),
+ placeholder: None,
+ oninput: link.callback(|e: InputData| Msg::UpdateAnniversary(e.value)),
+ value: self.anniversary.clone(),
+ typ: typ.clone(),
+ },
+ VCardPropertyInputField::Text{
+ label: "Birthday".to_string(),
+ id: Some("birthday".to_string()),
+ placeholder: None,
+ oninput: link.callback(|e: InputData| Msg::UpdateBirthday(e.value)),
+ value: self.birthday.clone(),
+ typ,
+ },
+ ]
+ }
+ fn is_empty(&self) -> bool {
+ self.anniversary.is_empty()
+ && self.birthday.is_empty()
+ }
+} \ No newline at end of file