Fixed property editing.

main
Josef Rokos 1 year ago
parent 55ca93406a
commit f3d6e0ea5b

@ -6,8 +6,7 @@ use crate::components::modal_box::DialogOpener;
#[component]
fn form_inner(property: ReadSignal<ResProperty>) -> impl IntoView {
let active_str = create_rw_signal(if property.get().active
{ "true".to_string() } else { "false".to_string() });
let active_str = create_rw_signal("false".to_string());
view! {
<input type="hidden" prop:value={move || property.get().id()} name="property[id]"/>
<div class="row">
@ -51,8 +50,9 @@ fn form_inner(property: ReadSignal<ResProperty>) -> impl IntoView {
</div>
<div class="row">
<div class="col mb-3">
<label for="slot" class="form-label">Time slot</label>
<label for="slot" class="form-label">{move || format!("Time slot {:?}", property.get().slot)}</label>
<select id="slot" name="property[slot]" class="form-select">
<option prop:value={move || format!("{:?}", property.get().slot)}>{move || format!("{:?}", property.get().slot)}</option>
<option value="Quarter" selected=move || property.get().slot == SlotType::Quarter>"Quarter an hour"</option>
<option value="Half" selected=move || property.get().slot == SlotType::Half>"Half an hour"</option>
<option value="Hour" selected=move || property.get().slot == SlotType::Hour>"Hour"</option>
@ -61,6 +61,7 @@ fn form_inner(property: ReadSignal<ResProperty>) -> impl IntoView {
</div>
</div>
{move || {
active_str.set(if property.get().active {"true".to_string()} else {"false".to_string()});
if property.get().id() != 0 {
view! {
<div class="row">
@ -70,8 +71,8 @@ fn form_inner(property: ReadSignal<ResProperty>) -> impl IntoView {
id="active"
class="form-check-input"
prop:checked={move || property.get().active}
on:click=move |_| active_str.set(if active_str.get() == "true".to_string()
{ "false".to_string() } else { "true".to_string() })
on:change=move |ev| active_str.set(if event_target_checked(&ev)
{ "true".to_string() } else { "false".to_string() })
/>
<label for="active" class="form-label">"Active"</label>
<input type="hidden" prop:value=active_str name="property[active]"/>

Loading…
Cancel
Save