summaryrefslogtreecommitdiff
path: root/src/view/name.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-02-04 13:30:15 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-02-04 13:30:15 +0100
commit69ceb1f9ec68e41029759a6fcff3168adb6df373 (patch)
tree194f21d845da5617e1c6d7fadaab380d10e472f7 /src/view/name.rs
parent51bf8e89ce07864b70d7138bbc3958faf499cc67 (diff)
downloadwasm-card-69ceb1f9ec68e41029759a6fcff3168adb6df373.tar.gz
wasm-card-69ceb1f9ec68e41029759a6fcff3168adb6df373.tar.bz2
minor refactoring + comments
Diffstat (limited to 'src/view/name.rs')
-rw-r--r--src/view/name.rs43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/view/name.rs b/src/view/name.rs
index 5b64bae..d864e35 100644
--- a/src/view/name.rs
+++ b/src/view/name.rs
@@ -1,14 +1,28 @@
use yew::services::ConsoleService;
+use yew::prelude::*;
+use yewtil::NeqAssign;
use yewtil::ptr::Irc;
use yewtil::ptr::Mrc;
use crate::viewmodel::Error;
use crate::view::WeakComponentLink;
-use yew::prelude::*;
-use yewtil::NeqAssign;
use crate::viewmodel::name::*;
use crate::viewmodel::VCardPropertyInputObject;
use super::VCardPropertyInputComponent;
+/// View Component for a `name` field
+///
+/// # Examples
+///
+/// ```compile_fail
+/// let html = html!{
+/// <NameView weak_link=some_weak_component_link
+/// generated=self.link.callback(
+/// |n: Irc<Name>|
+/// Msg::GeneratedName(some_name)
+/// )
+/// />
+/// };
+/// ```
pub struct NameView {
props: Props,
value: Mrc<Name>,
@@ -62,26 +76,11 @@ impl Component for NameView {
}
fn update(&mut self, msg: <Self as yew::Component>::Message) -> bool {
match msg {
- Msg::UpdatePrefix(p) => match self.value.get_mut() {
- Some(value) => value.prefix = p,
- None => ConsoleService::info("Couldn't get mutable reference to name"),
- },
- Msg::UpdateFirstName(f) => match self.value.get_mut() {
- Some(value) => value.first_name = f,
- None => ConsoleService::info("Couldn't get mutable reference to name"),
- },
- Msg::UpdateMiddleName(m) => match self.value.get_mut() {
- Some(value) => value.middle_name = m,
- None => ConsoleService::info("Couldn't get mutable reference to name"),
- },
- Msg::UpdateLastName(l) => match self.value.get_mut() {
- Some(value) => value.last_name = l,
- None => ConsoleService::info("Couldn't get mutable reference to name"),
- },
- Msg::UpdateSuffix(s) => match self.value.get_mut() {
- Some(value) => value.suffix = s,
- None => ConsoleService::info("Couldn't get mutable reference to name"),
- },
+ Msg::UpdatePrefix(p) => self.value.prefix = p,
+ Msg::UpdateFirstName(f) => self.value.first_name = f,
+ Msg::UpdateMiddleName(m) => self.value.middle_name = m,
+ Msg::UpdateLastName(l) => self.value.last_name = l,
+ Msg::UpdateSuffix(s) => self.value.suffix = s,
Msg::Generate => {
self.props.generated.emit(self.value.irc());
},