Leptos updated to 0.5
This commit is contained in:
+15
-16
@@ -8,8 +8,8 @@ pub struct DialogOpener {
|
||||
}
|
||||
|
||||
impl DialogOpener {
|
||||
pub fn new(cx: Scope) -> Self {
|
||||
let (visible, set_visible) = create_signal(cx, false);
|
||||
pub fn new() -> Self {
|
||||
let (visible, set_visible) = create_signal(false);
|
||||
DialogOpener {
|
||||
visible,
|
||||
set_visible,
|
||||
@@ -31,19 +31,18 @@ impl DialogOpener {
|
||||
|
||||
#[component]
|
||||
pub fn ModalDialog(
|
||||
cx: Scope,
|
||||
opener: DialogOpener,
|
||||
title: &'static str,
|
||||
children: Children,
|
||||
) -> impl IntoView {
|
||||
view! {cx,
|
||||
view! {
|
||||
<div class={ move || if opener.visible() {"modal fade show"} else {"modal fade"}}
|
||||
style={ move || if opener.visible() {"display: block;"} else {""}}
|
||||
id="modalCenter" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modalCenterTitle">{trl(cx, title)}</h5>
|
||||
<h5 class="modal-title" id="modalCenterTitle">{trl(title)}</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
@@ -51,7 +50,7 @@ pub fn ModalDialog(
|
||||
aria-label="Close"
|
||||
on:click=move |_| opener.hide()/>
|
||||
</div>
|
||||
{children(cx)}
|
||||
{children()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -59,33 +58,33 @@ pub fn ModalDialog(
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ModalBody(cx: Scope, children: Children) -> impl IntoView {
|
||||
view! {cx,
|
||||
pub fn ModalBody(children: Children) -> impl IntoView {
|
||||
view! {
|
||||
<div class="modal-body">
|
||||
{children(cx)}
|
||||
{children()}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ModalFooter(cx: Scope, children: Children) -> impl IntoView {
|
||||
view! {cx,
|
||||
pub fn ModalFooter(children: Children) -> impl IntoView {
|
||||
view! {
|
||||
<div class="modal-footer">
|
||||
{children(cx)}
|
||||
{children()}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn DlgNotLoaded(cx: Scope, opener: DialogOpener, title: &'static str) -> impl IntoView {
|
||||
view! {cx,
|
||||
pub fn DlgNotLoaded(opener: DialogOpener, title: &'static str) -> impl IntoView {
|
||||
view! {
|
||||
<ModalDialog opener=opener title=title>
|
||||
<ModalBody>
|
||||
<div>{trl(cx, "Entity not loaded")}</div>
|
||||
<div>{trl("Entity not loaded")}</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal" on:click=move |_| opener.hide()>
|
||||
{trl(cx, "Close")}
|
||||
{trl("Close")}
|
||||
</button>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
|
||||
@@ -3,24 +3,23 @@ use leptos::*;
|
||||
|
||||
#[component]
|
||||
pub fn ServerErr(
|
||||
cx: Scope,
|
||||
result: RwSignal<Option<Result<(), ServerFnError>>>,
|
||||
opener: DialogOpener,
|
||||
) -> impl IntoView {
|
||||
view! {cx, {move || {
|
||||
view! {{move || {
|
||||
if let Some(val) = result.get() {
|
||||
if let Err(e) = val {
|
||||
view! {cx,
|
||||
view! {
|
||||
<div class="alert alert-danger">
|
||||
"Server error: " {e.to_string()}
|
||||
</div>
|
||||
}
|
||||
} else {
|
||||
opener.hide();
|
||||
view! {cx, <div></div>}
|
||||
view! {<div></div>}
|
||||
}
|
||||
} else {
|
||||
view! {cx, <div></div>}
|
||||
view! {<div></div>}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -4,33 +4,32 @@ use crate::validator::Validator;
|
||||
|
||||
#[component]
|
||||
pub fn ValidationErr(
|
||||
cx: Scope,
|
||||
validator: Validator,
|
||||
) -> impl IntoView {
|
||||
view! {cx, {move || {
|
||||
view! {{move || {
|
||||
if !validator.is_valid() {
|
||||
if let Some(msgs) = validator.messages() {
|
||||
let out_msgs = msgs.into_iter().map(move |e| {
|
||||
view! {cx,
|
||||
view! {
|
||||
<div class="alert alert-danger">
|
||||
{trl(cx, &e)}
|
||||
{trl(&e)}
|
||||
</div>
|
||||
}
|
||||
}).collect_view(cx);
|
||||
view! {cx,
|
||||
}).collect_view();
|
||||
view! {
|
||||
<div>
|
||||
{out_msgs}
|
||||
</div>
|
||||
}
|
||||
} else {
|
||||
view! {cx,
|
||||
view! {
|
||||
<div class="alert alert-danger">
|
||||
"Validation error"
|
||||
</div>
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view! {cx, <div></div>}
|
||||
view! {<div></div>}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user