From c1a61d28a4658eeba2c4b41a4ec6abada5b54431 Mon Sep 17 00:00:00 2001 From: Daan Vanoverloop Date: Fri, 16 Sep 2022 12:01:34 +0200 Subject: [PATCH] Bugfix --- core/src/edit.rs | 11 +---------- web/dist/index.html | 6 +++--- web/src/pages/events.rs | 19 ++++++------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/core/src/edit.rs b/core/src/edit.rs index b92e525..d2d5685 100644 --- a/core/src/edit.rs +++ b/core/src/edit.rs @@ -288,7 +288,6 @@ where vec.get() .as_ref() .iter() - .cloned() .map(|x| x.get().as_ref().clone()) .collect(), ) @@ -298,7 +297,6 @@ where let onremove = move |item: &'a Signal| { move |_| { let cloned = vec.get().as_ref().clone(); - debug!("{:#?}", item.get()); vec.set( cloned .into_iter() @@ -478,13 +476,6 @@ where let ctx = use_context::(cx); create_effect(cx, || { - debug!( - "{}", - (*value.get()) - .parse::() - .unwrap_or(T::default()) - .to_string() - ); props .state .set((*value.get()).parse::().unwrap_or(T::default()).into()) @@ -497,7 +488,7 @@ where view=move |cx: BoundedScope<'_, 'a>, x| { let x = create_ref(cx, x); view! { cx, - option(value=x.to_string()) { (x.to_string()) } + option(value=x.to_string(), selected=x.to_string()==*value.get()) { (x.to_string()) } } }, ) diff --git a/web/dist/index.html b/web/dist/index.html index 0ca1993..f2efc2b 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -6,7 +6,7 @@ LAN Party - - + + - \ No newline at end of file + \ No newline at end of file diff --git a/web/src/pages/events.rs b/web/src/pages/events.rs index 16c90df..015efa4 100644 --- a/web/src/pages/events.rs +++ b/web/src/pages/events.rs @@ -1,8 +1,11 @@ +use std::ops::Deref; + use anyhow::anyhow; use lan_party_core::{ components::Block, edit::IntoEdit, event::{Event, EventOutcome, EventSpec, EventUpdate}, + util::WithContext, view::IntoView, }; use log::debug; @@ -31,7 +34,7 @@ pub fn EventsPage<'a, G: Html>(cx: Scope<'a>) -> View { let event_spec = create_signal(cx, EventSpec::default()); let event_update = create_signal(cx, EventUpdate::default()); - let event_update_name = create_signal(cx, String::new()); + let event_update_name = create_signal(cx, WithContext::::from(String::new())); let current_event = create_signal(cx, String::new()); let show_outcome = create_signal(cx, false); @@ -161,22 +164,12 @@ pub fn EventsPage<'a, G: Html>(cx: Scope<'a>) -> View { br() Block(title="Update an event".into()) { label { "Event name" } - select(bind:value=event_update_name) { - Indexed( - iterable=&events.get(), - view=move |cx, event| { - let event = create_ref(cx, event); - view! { cx, - option(value=event.name) { (event.name) } - } - }, - ) - } + (event_update_name.edit(cx)) (event_update.edit(cx)) Button( icon="mdi-check".into(), onclick=move |_| dispatch(Msg::Update( - event_update_name.get().as_ref().clone(), + event_update_name.get().as_ref().deref().clone(), event_update.get().as_ref().clone() )) )