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