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/mod.rs | 82 ++------------------------------------------------------- 1 file changed, 2 insertions(+), 80 deletions(-) (limited to 'src/view/mod.rs') diff --git a/src/view/mod.rs b/src/view/mod.rs index cbff0fd..691f19a 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -1,81 +1,3 @@ -use crate::viewmodel::*; -use std::cell::RefCell; -use std::ops::Deref; -use std::rc::Rc; -use yew::prelude::*; - -pub mod address; -pub mod dates; pub mod main; -pub mod name; -pub mod organizational; -pub mod telephone; - -#[derive(Clone, PartialEq, Properties)] -pub struct InputProps -where - O: VCardPropertyInputObject + Clone, - C: VCardPropertyInputComponent + Clone, -{ - pub generated: Callback, - pub weak_link: WeakComponentLink, -} - -/// Trait for types that represent an input component for a vcard property. -pub trait VCardPropertyInputComponent>: - Component + Clone + PartialEq -{ - /// Returns the object containing the input data. - fn get_input_object(&self) -> T; - /// Getter function for the title of the component - fn get_title(&self) -> String; - /// Getter function for an eventual error. - fn get_error(&self) -> Option; - /// Returns the error as `Html` - fn render_error(&self) -> Html { - html! { - <> - { - if self.get_error().is_some() { - html!{ -
- { self.get_error().unwrap().msg } -
- } - } else { - html!{} - } - } - - } - } -} - -/// Weak link; Useful for being able to have a list of subcomponents. -pub struct WeakComponentLink(Rc>>>); - -impl Clone for WeakComponentLink { - fn clone(&self) -> Self { - Self(Rc::clone(&self.0)) - } -} - -impl Default for WeakComponentLink { - fn default() -> Self { - Self(Rc::default()) - } -} - -impl Deref for WeakComponentLink { - type Target = Rc>>>; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl PartialEq for WeakComponentLink { - fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) - } -} +pub mod property_group; +pub mod weak_links; -- cgit v1.2.3