summaryrefslogtreecommitdiff
path: root/src/view/main.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-02-11 12:07:22 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-02-11 12:07:22 +0100
commit0660151a8b641fa0a23dde2598132029970f7ae4 (patch)
tree0bdeb1108419add4570f278795f0bfd0f5366856 /src/view/main.rs
parent036a567bae8346eb38f9237f59645dbcc4f1cd8c (diff)
downloadwasm-card-0660151a8b641fa0a23dde2598132029970f7ae4.tar.gz
wasm-card-0660151a8b641fa0a23dde2598132029970f7ae4.tar.bz2
refactoring - reduced code size by about a third
Diffstat (limited to 'src/view/main.rs')
-rw-r--r--src/view/main.rs42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/view/main.rs b/src/view/main.rs
index 196afa0..d35fb59 100644
--- a/src/view/main.rs
+++ b/src/view/main.rs
@@ -1,18 +1,14 @@
-use super::address::{self, AddressView};
-use super::dates::{self, DatesView};
-use super::name::{self, NameView};
-use super::WeakComponentLink;
-use crate::view::organizational::{self, OrganizationalView};
-use crate::view::telephone::{self, TelephoneView};
-use crate::viewmodel::address::Address;
-use crate::viewmodel::dates::Dates;
-use crate::viewmodel::name::Name;
-use crate::viewmodel::organizational::Organizational;
-use crate::viewmodel::telephone::Telephone;
-use crate::viewmodel::utility::*;
-use crate::viewmodel::vcard::VCardData;
-use crate::viewmodel::Error;
-use crate::viewmodel::VCardPropertyInputObject;
+use crate::view::property_group::PropertyGroupInputComponent;
+use crate::view::weak_links::WeakComponentLink;
+use crate::model::address::*;
+use crate::model::dates::*;
+use crate::model::name::*;
+use crate::model::organizational::*;
+use crate::model::telephone::*;
+use crate::model::utility::*;
+use crate::model::vcard::VCardData;
+use crate::model::Error;
+use crate::model::VCardPropertyInputObject;
use boolinator::Boolinator;
use chrono::prelude::*;
use genpdf::Element as _;
@@ -25,6 +21,12 @@ use yew::prelude::*;
use yew::services::ConsoleService;
use yewtil::ptr::Mrc;
+type NameView = PropertyGroupInputComponent<Name, NameMsg>;
+type AddressView = PropertyGroupInputComponent<Address, AddressMsg>;
+type DatesView = PropertyGroupInputComponent<Dates, DatesMsg>;
+type OrganizationalView = PropertyGroupInputComponent<Organizational, OrganizationalMsg>;
+type TelephoneView = PropertyGroupInputComponent<Telephone, TelephoneMsg>;
+
pub struct MainView {
link: ComponentLink<Self>,
error: Option<Error>,
@@ -117,27 +119,27 @@ impl Component for MainView {
{
for name_link in self.name_links.iter() {
let name_link = name_link.borrow().clone().unwrap();
- name_link.send_message(name::Msg::Generate);
+ name_link.send_message(NameMsg::Generate);
}
for address_link in self.address_links.iter() {
let address_link = address_link.borrow().clone().unwrap();
- address_link.send_message(address::Msg::Generate);
+ address_link.send_message(AddressMsg::Generate);
}
for telephone_link in self.telephone_links.iter() {
let telephone_link = telephone_link.borrow().clone().unwrap();
- telephone_link.send_message(telephone::Msg::Generate);
+ telephone_link.send_message(TelephoneMsg::Generate);
}
for dates_link in self.dates_links.iter() {
let dates_link = dates_link.borrow().clone().unwrap();
- dates_link.send_message(dates::Msg::Generate)
+ dates_link.send_message(DatesMsg::Generate)
}
for organizational_links in self.organizational_links.iter() {
let organizational_link = organizational_links.borrow().clone().unwrap();
- organizational_link.send_message(organizational::Msg::Generate)
+ organizational_link.send_message(OrganizationalMsg::Generate)
}
}
/*