From 0660151a8b641fa0a23dde2598132029970f7ae4 Mon Sep 17 00:00:00 2001 From: jelemux Date: Thu, 11 Feb 2021 12:07:22 +0100 Subject: refactoring - reduced code size by about a third --- src/view/main.rs | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/view/main.rs') 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; +type AddressView = PropertyGroupInputComponent; +type DatesView = PropertyGroupInputComponent; +type OrganizationalView = PropertyGroupInputComponent; +type TelephoneView = PropertyGroupInputComponent; + pub struct MainView { link: ComponentLink, error: Option, @@ -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) } } /* -- cgit v1.2.3