This commit is contained in:
Daan Vanoverloop 2022-09-16 12:01:34 +02:00
parent f2d6d3a20f
commit c1a61d28a4
Signed by: Danacus
GPG Key ID: F2272B50E129FC5C
3 changed files with 10 additions and 26 deletions

View File

@ -288,7 +288,6 @@ where
vec.get() vec.get()
.as_ref() .as_ref()
.iter() .iter()
.cloned()
.map(|x| x.get().as_ref().clone()) .map(|x| x.get().as_ref().clone())
.collect(), .collect(),
) )
@ -298,7 +297,6 @@ where
let onremove = move |item: &'a Signal<T>| { let onremove = move |item: &'a Signal<T>| {
move |_| { move |_| {
let cloned = vec.get().as_ref().clone(); let cloned = vec.get().as_ref().clone();
debug!("{:#?}", item.get());
vec.set( vec.set(
cloned cloned
.into_iter() .into_iter()
@ -478,13 +476,6 @@ where
let ctx = use_context::<Ctx>(cx); let ctx = use_context::<Ctx>(cx);
create_effect(cx, || { create_effect(cx, || {
debug!(
"{}",
(*value.get())
.parse::<T>()
.unwrap_or(T::default())
.to_string()
);
props props
.state .state
.set((*value.get()).parse::<T>().unwrap_or(T::default()).into()) .set((*value.get()).parse::<T>().unwrap_or(T::default()).into())
@ -497,7 +488,7 @@ where
view=move |cx: BoundedScope<'_, 'a>, x| { view=move |cx: BoundedScope<'_, 'a>, x| {
let x = create_ref(cx, x); let x = create_ref(cx, x);
view! { cx, view! { cx,
option(value=x.to_string()) { (x.to_string()) } option(value=x.to_string(), selected=x.to_string()==*value.get()) { (x.to_string()) }
} }
}, },
) )

6
web/dist/index.html vendored
View File

@ -6,7 +6,7 @@
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
<title>LAN Party</title> <title>LAN Party</title>
<link rel="preload" href="/index-bca49fe60bf0b94f_bg.wasm" as="fetch" type="application/wasm" crossorigin=""> <link rel="preload" href="/index-495632ef4eca1348_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/index-bca49fe60bf0b94f.js"></head> <link rel="modulepreload" href="/index-495632ef4eca1348.js"></head>
<body> <body>
<script type="module">import init from '/index-bca49fe60bf0b94f.js';init('/index-bca49fe60bf0b94f_bg.wasm');</script></body></html> <script type="module">import init from '/index-495632ef4eca1348.js';init('/index-495632ef4eca1348_bg.wasm');</script></body></html>

View File

@ -1,8 +1,11 @@
use std::ops::Deref;
use anyhow::anyhow; use anyhow::anyhow;
use lan_party_core::{ use lan_party_core::{
components::Block, components::Block,
edit::IntoEdit, edit::IntoEdit,
event::{Event, EventOutcome, EventSpec, EventUpdate}, event::{Event, EventOutcome, EventSpec, EventUpdate},
util::WithContext,
view::IntoView, view::IntoView,
}; };
use log::debug; use log::debug;
@ -31,7 +34,7 @@ pub fn EventsPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
let event_spec = create_signal(cx, EventSpec::default()); let event_spec = create_signal(cx, EventSpec::default());
let event_update = create_signal(cx, EventUpdate::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::<Events, String>::from(String::new()));
let current_event = create_signal(cx, String::new()); let current_event = create_signal(cx, String::new());
let show_outcome = create_signal(cx, false); let show_outcome = create_signal(cx, false);
@ -161,22 +164,12 @@ pub fn EventsPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
br() br()
Block(title="Update an event".into()) { Block(title="Update an event".into()) {
label { "Event name" } label { "Event name" }
select(bind:value=event_update_name) { (event_update_name.edit(cx))
Indexed(
iterable=&events.get(),
view=move |cx, event| {
let event = create_ref(cx, event);
view! { cx,
option(value=event.name) { (event.name) }
}
},
)
}
(event_update.edit(cx)) (event_update.edit(cx))
Button( Button(
icon="mdi-check".into(), icon="mdi-check".into(),
onclick=move |_| dispatch(Msg::Update( 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() event_update.get().as_ref().clone()
)) ))
) )