summaryrefslogtreecommitdiff
path: root/src/model/other_identification.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-02-17 22:27:41 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-02-17 22:27:41 +0100
commit9698e6952cb568f6dce49b35bd47b52d992c0f9a (patch)
tree1c8cff0b2c6824653da68b94a81bbbfb314f01dd /src/model/other_identification.rs
parentd0d42c5ae00560e4464479a98df90ed063a1c773 (diff)
downloadwasm-card-9698e6952cb568f6dce49b35bd47b52d992c0f9a.tar.gz
wasm-card-9698e6952cb568f6dce49b35bd47b52d992c0f9a.tar.bz2
refactor: put input_fields and property_groups into their own modules
Diffstat (limited to 'src/model/other_identification.rs')
-rw-r--r--src/model/other_identification.rs116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/model/other_identification.rs b/src/model/other_identification.rs
deleted file mode 100644
index a01b818..0000000
--- a/src/model/other_identification.rs
+++ /dev/null
@@ -1,116 +0,0 @@
-use super::*;
-
-/// Type that represents the vcard `anniversary` and `birthday` properties.
-#[derive(Clone, Debug, PartialEq)]
-pub struct OtherIdentification {
- pub nickname: String,
- pub photo: Option<File>,
- pub birthday: String,
- pub anniversary: String,
- pub gender: String,
-}
-
-#[derive(Clone, PartialEq)]
-pub enum OtherIdentificationMsg {
- UpdateNickname(String),
- UpdatePhoto(Option<File>),
- UpdateBirthday(String),
- UpdateAnniversary(String),
- UpdateGender(String),
-
- Generate,
-
- Nope,
-}
-
-impl VCardPropertyInputGroupObject<OtherIdentificationMsg> for OtherIdentification {
- fn new() -> Self {
- Self {
- nickname: String::new(),
- photo: None,
- birthday: String::new(),
- anniversary: String::new(),
- gender: String::new(),
- }
- }
- fn get_title(&self) -> std::string::String {
- "Other Identification Properties".to_string()
- }
- fn get_input_fields(
- &self,
- link: &yew::html::Scope<PropertyGroupInputComponent<Self, OtherIdentificationMsg>>,
- ) -> std::vec::Vec<VCardPropertyInputField> {
- vec![
- VCardPropertyInputField::Text {
- label: String::from("Nickname"),
- id: Some(String::from("nickname")),
- placeholder: None,
- oninput: link
- .callback(|e: InputData| OtherIdentificationMsg::UpdateNickname(e.value)),
- value: self.nickname.clone(),
- typ: String::from("text"),
- },
- VCardPropertyInputField::File {
- label: String::from("Photo"),
- name: String::from("photo"),
- callback: link
- .callback(|file: Option<File>| OtherIdentificationMsg::UpdatePhoto(file)),
- value: self.photo.clone(),
- },
- VCardPropertyInputField::Text {
- label: "Birthday".to_string(),
- id: Some("birthday".to_string()),
- placeholder: None,
- oninput: link
- .callback(|e: InputData| OtherIdentificationMsg::UpdateBirthday(e.value)),
- value: self.birthday.clone(),
- typ: String::from("date"),
- },
- VCardPropertyInputField::Text {
- label: "Anniversary".to_string(),
- id: Some("anniversary".to_string()),
- placeholder: None,
- oninput: link
- .callback(|e: InputData| OtherIdentificationMsg::UpdateAnniversary(e.value)),
- value: self.anniversary.clone(),
- typ: String::from("date"),
- },
- VCardPropertyInputField::Select {
- label: String::from("Gender"),
- id: Some(String::from("gender")),
- options: vec![
- (String::from(""), String::from("Select one")),
- (String::from("M"), String::from("Male")),
- (String::from("F"), String::from("Female")),
- (String::from("O"), String::from("Other")),
- (String::from("N"), String::from("Not applicable")),
- (String::from("U"), String::from("Unknown")),
- ],
- onchange: link.callback(|c: ChangeData| match c {
- ChangeData::Select(v) => OtherIdentificationMsg::UpdateGender(v.value()),
- _ => OtherIdentificationMsg::Nope,
- }),
- value: self.gender.clone(),
- },
- ]
- }
- fn update(
- &mut self,
- props: InputProps<Self, OtherIdentificationMsg>,
- msg: <PropertyGroupInputComponent<Self, OtherIdentificationMsg> as yew::Component>::Message,
- ) -> bool {
- match msg {
- OtherIdentificationMsg::UpdateNickname(n) => self.nickname = n,
- OtherIdentificationMsg::UpdatePhoto(p) => self.photo = p,
- OtherIdentificationMsg::UpdateBirthday(b) => self.birthday = b,
- OtherIdentificationMsg::UpdateAnniversary(a) => self.anniversary = a,
- OtherIdentificationMsg::UpdateGender(g) => self.gender = g,
- OtherIdentificationMsg::Generate => props.generated.emit(self.clone()),
- OtherIdentificationMsg::Nope => (),
- };
- true
- }
- fn is_empty(&self) -> bool {
- self.anniversary.is_empty() && self.birthday.is_empty()
- }
-}