Leptos updated to 0.5
This commit is contained in:
Generated
+52
-81
@@ -592,28 +592,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cached"
|
||||
version = "0.44.0"
|
||||
version = "0.45.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b195e4fbc4b6862bbd065b991a34750399c119797efff72492f28a5864de8700"
|
||||
checksum = "90eb5776f28a149524d1d8623035760b4454ec881e8cf3838fa8d7e1b11254b3"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"cached_proc_macro",
|
||||
"cached_proc_macro_types",
|
||||
"futures",
|
||||
"hashbrown 0.13.2",
|
||||
"instant",
|
||||
"once_cell",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cached_proc_macro"
|
||||
version = "0.17.0"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b48814962d2fd604c50d2b9433c2a41a0ab567779ee2c02f7fba6eca1221f082"
|
||||
checksum = "7da8245dd5f576a41c3b76247b54c15b0e43139ceeb4f732033e15be7c005176"
|
||||
dependencies = [
|
||||
"cached_proc_macro_types",
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -977,18 +973,6 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "669a445ee724c5c69b1b06fe0b63e70a1c84bc9bb7d9696cd4f4e3ec45050408"
|
||||
|
||||
[[package]]
|
||||
name = "educe"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "079044df30bb07de7d846d41a184c4b00e66ebdac93ee459253474f3a47e50ae"
|
||||
dependencies = [
|
||||
"enum-ordinalize",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
@@ -1007,19 +991,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-ordinalize"
|
||||
version = "3.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4f76552f53cefc9a7f64987c3701b99d982f7690606fd67de1d09712fbf52f1"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.28",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
@@ -1627,9 +1598,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d08fd7674758f996050217a8aff9e584d033c2e5c882cd3f52fb5090dc361dd"
|
||||
checksum = "4d811de15430df8e4886afe09e5e741a886876c51ea32b8f11e0963ba9415e4b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"leptos_config",
|
||||
@@ -1640,13 +1611,16 @@ dependencies = [
|
||||
"server_fn",
|
||||
"tracing",
|
||||
"typed-builder",
|
||||
"typed-builder-macro",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_actix"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c122547e0a04d6b2efaef999b3165f03eb1b1284fdb298f05bde9107ed16ec2"
|
||||
checksum = "82ae271646ca49e2464ee454428775064a330658559e1c92d20170ee9c12b674"
|
||||
dependencies = [
|
||||
"actix-http",
|
||||
"actix-web",
|
||||
@@ -1658,14 +1632,15 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_config"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e5c13a1ae92b5a545cc013205288751fb2fef521de5a092067fd8429ad343e8"
|
||||
checksum = "92015175317cafe8e651289a48bc3cdd68c276c6054229f20dbee73a81fea21f"
|
||||
dependencies = [
|
||||
"config",
|
||||
"regex",
|
||||
@@ -1676,14 +1651,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_dom"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35994afab1dca68a46c7b40a29d40d84a2e06e1b1fa0d5c5915ade4f4f2611ee"
|
||||
checksum = "ba03b4357fd08d2c84da3572f66f47973703e0ef6166c2dd0db4766f83310a72"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"cfg-if",
|
||||
"drain_filter_polyfill",
|
||||
"educe",
|
||||
"futures",
|
||||
"getrandom",
|
||||
"html-escape",
|
||||
@@ -1695,6 +1669,7 @@ dependencies = [
|
||||
"pad-adapter",
|
||||
"paste",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"server_fn",
|
||||
"smallvec",
|
||||
@@ -1706,9 +1681,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_hot_reload"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a088a4dd5489941a9cc73719148f217c78f0d761a50e025739653c3b7f9d484"
|
||||
checksum = "21cade49ea1a5e72b3a546b4507b3ef4e43586d306b7f20c180ed6a3bf855665"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"camino",
|
||||
@@ -1724,9 +1699,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_integration_utils"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfd4a097f1870172f5079e44af99fb5d5f02cd856db6b32a6ac98cc58f1a1f47"
|
||||
checksum = "cb2d6a0d32b073fa1a9326f83b99f02f60a0e159fe0a7ce53d2708318114a6a3"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"leptos",
|
||||
@@ -1738,9 +1713,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_macro"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bdd7a21d20ca21bb12d67d050d4b0ad9973b156bce98f499f8b1789f11959dd"
|
||||
checksum = "befb8d664269550a918a6a160c10792951a37e95b542ca454c191ec7480505de"
|
||||
dependencies = [
|
||||
"attribute-derive",
|
||||
"cfg-if",
|
||||
@@ -1761,9 +1736,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_meta"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed4e4855b6d0047f1cdbf0e9d41b76a1b596ec374f844d2bae1e48f2d2df70d8"
|
||||
checksum = "6c77f3ae209084fae41024f3023fa816a6fe91a45da00729ff349dd0ddb9b2c0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"indexmap 2.0.0",
|
||||
@@ -1775,9 +1750,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_reactive"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5500318e457b4ab841722a5988e8db0def1ee7ac66b816ba9073c100c4984a"
|
||||
checksum = "4382426f6e79d209408e362883b9542f934bafb3b98cc957f94e085f707508a0"
|
||||
dependencies = [
|
||||
"base64 0.21.2",
|
||||
"cfg-if",
|
||||
@@ -1800,9 +1775,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_router"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57a6cd29a56992923c9bad3c814ab9d7a78bf0bfec80c8f4dfbf049144fa5828"
|
||||
checksum = "b250d706ddbfb9991c5615b35dd27596e5b23024d8ee50fe4717aa21f67bb3b1"
|
||||
dependencies = [
|
||||
"cached",
|
||||
"cfg-if",
|
||||
@@ -1812,7 +1787,6 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"leptos",
|
||||
"linear-map",
|
||||
"log",
|
||||
"lru",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
@@ -1830,9 +1804,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leptos_server"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a28d958deee3c7ffda892a67ac4a47500aebbaf00b11d217cfe6fd494c297818"
|
||||
checksum = "0dfe03995c38441e45dc0d44828b657dbcff3b87c8ce5c2f4219297226c752b0"
|
||||
dependencies = [
|
||||
"inventory",
|
||||
"lazy_static",
|
||||
@@ -1925,11 +1899,11 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.10.0"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e"
|
||||
checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21"
|
||||
dependencies = [
|
||||
"hashbrown 0.13.2",
|
||||
"hashbrown 0.14.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2824,9 +2798,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "server_fn"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "644216cf54c944da2d7fc7a75337a35dc39de19130be3fd88fd58674719a1b5b"
|
||||
checksum = "0c5839ea169c9ac14c08d368ed523d0896b050cf18d754fcbde19923995f19be"
|
||||
dependencies = [
|
||||
"ciborium",
|
||||
"const_format",
|
||||
@@ -2849,9 +2823,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "server_fn_macro"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1db2cd1a054f5c6ec168982241f6cdad083591d6c68449e666c839ec421bfc54"
|
||||
checksum = "80116501286c018b8d6330be8b2bc286ed801f59439f2fbfad2b79d96942c2a2"
|
||||
dependencies = [
|
||||
"const_format",
|
||||
"proc-macro-error",
|
||||
@@ -2864,9 +2838,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "server_fn_macro_default"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0-rc1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35ee7b18c66e7a30b1855096cee24d540925825ce91193f42fae322033b109c1"
|
||||
checksum = "709cc458808a38f20b9d0121a3022fa35b704e5e577d352b92b5dd4ad78f4923"
|
||||
dependencies = [
|
||||
"server_fn_macro",
|
||||
"syn 2.0.28",
|
||||
@@ -3358,21 +3332,9 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.28",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.14"
|
||||
@@ -3454,13 +3416,22 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
||||
|
||||
[[package]]
|
||||
name = "typed-builder"
|
||||
version = "0.14.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64cba322cb9b7bc6ca048de49e83918223f35e7a86311267013afff257004870"
|
||||
checksum = "6605aaa56cce0947127ffa0675a8a1b181f87773364390174de60a86ab9085f1"
|
||||
dependencies = [
|
||||
"typed-builder-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typed-builder-macro"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a6a6884f6a890a012adcc20ce498f30ebdc70fb1ea242c333cc5f435b0b3871"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.28",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+4
-4
@@ -12,10 +12,10 @@ actix-web = { version = "4", optional = true, features = ["macros"] }
|
||||
actix-session = { version = "0.7.2", optional = true, features = ["cookie-session"] }
|
||||
console_error_panic_hook = "0.1"
|
||||
cfg-if = "1"
|
||||
leptos = { version = "0.4.8" }
|
||||
leptos_meta = { version = "0.4.8" }
|
||||
leptos_actix = { version = "0.4.8", optional = true }
|
||||
leptos_router = { version = "0.4.8" }
|
||||
leptos = { version = "0.5.0-rc1" }
|
||||
leptos_meta = { version = "0.5.0-rc1" }
|
||||
leptos_actix = { version = "0.5.0-rc1", optional = true }
|
||||
leptos_router = { version = "0.5.0-rc1" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
wasm-bindgen = "=0.2.87"
|
||||
web-sys = { version = "0.3.61", features = ["Navigator"] }
|
||||
|
||||
+7
-8
@@ -6,13 +6,12 @@ use crate::pages::home_page::HomePage;
|
||||
use crate::pages::settings::Settings;
|
||||
|
||||
#[component]
|
||||
pub fn App(cx: Scope) -> impl IntoView {
|
||||
pub fn App() -> impl IntoView {
|
||||
// Provides context that manages stylesheets, titles, meta tags, etc.
|
||||
provide_meta_context(cx);
|
||||
//provide_context(cx, DialogOpener::new(cx));
|
||||
provide_meta_context();
|
||||
//provide_context(DialogOpener::new());
|
||||
|
||||
view! {
|
||||
cx,
|
||||
<Html
|
||||
lang="cz"
|
||||
dir="ltr"
|
||||
@@ -61,7 +60,7 @@ pub fn App(cx: Scope) -> impl IntoView {
|
||||
<li class="menu-item">
|
||||
<a href="/" class="menu-link">
|
||||
<i class="menu-icon tf-icons bx bx-home-circle"></i>
|
||||
<div data-i18n="Analytics">{trl(cx, "Dashboard")}</div>
|
||||
<div data-i18n="Analytics">{trl("Dashboard")}</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
@@ -173,8 +172,8 @@ pub fn App(cx: Scope) -> impl IntoView {
|
||||
<Router>
|
||||
<main>
|
||||
<Routes>
|
||||
<Route path="" view=|cx| view! { cx, <HomePage/> }/>
|
||||
<Route path="settings" view=|cx| view! { cx, <Settings/> }/>
|
||||
<Route path="" view=|| view! { <HomePage/> }/>
|
||||
<Route path="settings" view=|| view! { <Settings/> }/>
|
||||
</Routes>
|
||||
</main>
|
||||
</Router>
|
||||
@@ -212,7 +211,7 @@ pub fn App(cx: Scope) -> impl IntoView {
|
||||
<Router>
|
||||
<main>
|
||||
<Routes>
|
||||
<Route path="" view=|cx| view! { cx, <HomePage/> }/>
|
||||
<Route path="" view=|| view! { <HomePage/> }/>
|
||||
</Routes>
|
||||
</main>
|
||||
</Router>
|
||||
|
||||
+4
-12
@@ -2,16 +2,12 @@ use crate::backend::data::Company;
|
||||
use leptos::*;
|
||||
|
||||
#[server(GetCompany, "/api", "Url", "get_company")]
|
||||
pub async fn get_company(cx: Scope) -> Result<Company, ServerFnError> {
|
||||
pub async fn get_company() -> Result<Company, ServerFnError> {
|
||||
use crate::backend::AppData;
|
||||
use actix_web::web::Data;
|
||||
use leptos_actix::extract;
|
||||
|
||||
let pool = extract(
|
||||
cx,
|
||||
|data: Data<AppData>| async move { data.db_pool().clone() },
|
||||
)
|
||||
.await?;
|
||||
let pool = extract(|data: Data<AppData>| async move { data.db_pool().clone() }).await?;
|
||||
|
||||
let cmp = sqlx::query_as::<_, Company>("SELECT * FROM company")
|
||||
.fetch_one(&pool)
|
||||
@@ -21,16 +17,12 @@ pub async fn get_company(cx: Scope) -> Result<Company, ServerFnError> {
|
||||
}
|
||||
|
||||
#[server(UpdateCompany, "/api", "Url", "update_company")]
|
||||
pub async fn update_company(cx: Scope, company: Company) -> Result<(), ServerFnError> {
|
||||
pub async fn update_company(company: Company) -> Result<(), ServerFnError> {
|
||||
use crate::backend::AppData;
|
||||
use actix_web::web::Data;
|
||||
use leptos_actix::extract;
|
||||
|
||||
let pool = extract(
|
||||
cx,
|
||||
|data: Data<AppData>| async move { data.db_pool().clone() },
|
||||
)
|
||||
.await?;
|
||||
let pool = extract(|data: Data<AppData>| async move { data.db_pool().clone() }).await?;
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE company SET name = $1, street = $2, house_number = $3, zip_code = $4, city = $5 \
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate)]
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct Company {
|
||||
id: i32,
|
||||
|
||||
+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>}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ if #[cfg(feature = "hydrate")] {
|
||||
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
leptos::mount_to_body(move |cx| {
|
||||
view! { cx, <App/> }
|
||||
leptos::mount_to_body(move || {
|
||||
view! { <App/> }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ lazy_static! {
|
||||
};
|
||||
}
|
||||
|
||||
fn get_locales(cx: Scope) -> Vec<Option<String>> {
|
||||
let (loc, set_loc) = create_signal(cx, Vec::new());
|
||||
fn get_locales() -> Vec<Option<String>> {
|
||||
let (loc, set_loc) = create_signal(Vec::new());
|
||||
|
||||
create_effect(cx, move |_| {
|
||||
create_effect(move |_| {
|
||||
let js_locales = window().navigator().languages();
|
||||
set_loc.update(|l| *l = js_locales.into_iter().map(|val| val.as_string()).collect::<Vec<_>>());
|
||||
});
|
||||
@@ -35,8 +35,8 @@ fn get_locales(cx: Scope) -> Vec<Option<String>> {
|
||||
loc.get_untracked()
|
||||
}
|
||||
|
||||
pub fn get_dictionary(cx: Scope) -> Option<&'static HashMap<&'static str, &'static str>> {
|
||||
let locs = get_locales(cx);
|
||||
pub fn get_dictionary() -> Option<&'static HashMap<&'static str, &'static str>> {
|
||||
let locs = get_locales();
|
||||
|
||||
for loc in locs {
|
||||
if let Some(key) = loc {
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ use crate::locales::catalogues::get_dictionary;
|
||||
|
||||
mod catalogues;
|
||||
|
||||
pub fn trl(cx: Scope, phrase: &str) -> impl Fn() -> String {
|
||||
pub fn trl(phrase: &str) -> impl Fn() -> String {
|
||||
let mut translated = phrase;
|
||||
if let Some(dict) = get_dictionary(cx) {
|
||||
if let Some(dict) = get_dictionary() {
|
||||
if let Some(p) = dict.get(phrase.to_string().as_str()) {
|
||||
translated = *p;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,3 +1,4 @@
|
||||
use actix_web::middleware::DefaultHeaders;
|
||||
use sqlx::migrate;
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
|
||||
@@ -18,7 +19,7 @@ async fn main() -> std::io::Result<()> {
|
||||
let conf = get_configuration(None).await.unwrap();
|
||||
let addr = conf.leptos_options.site_addr;
|
||||
// Generate the list of routes in your Leptos App
|
||||
let routes = generate_route_list(|cx| view! { cx, <App/> });
|
||||
let routes = generate_route_list(|| view! { <App/> });
|
||||
let key = Key::generate();
|
||||
|
||||
let pool = PgPoolOptions::new()
|
||||
@@ -41,7 +42,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.leptos_routes(
|
||||
leptos_options.to_owned(),
|
||||
routes.to_owned(),
|
||||
|cx| view! { cx, <App/> },
|
||||
|| view! { <App/> },
|
||||
)
|
||||
.service(Files::new("/", site_root))
|
||||
//.wrap(middleware::Compress::default())
|
||||
@@ -70,9 +71,9 @@ pub fn main() {
|
||||
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
leptos::mount_to_body(move |cx| {
|
||||
leptos::mount_to_body(move || {
|
||||
// note: for testing it may be preferrable to replace this with a
|
||||
// more specific component, although leptos_router should still work
|
||||
view! {cx, <App/> }
|
||||
view! {<App/> }
|
||||
});
|
||||
}
|
||||
|
||||
+90
-100
@@ -12,108 +12,98 @@ use crate::components::validation_err::ValidationErr;
|
||||
|
||||
#[component]
|
||||
pub fn CompanyEdit(
|
||||
cx: Scope,
|
||||
company: ReadSignal<Option<Company>>,
|
||||
company: ReadSignal<Company>,
|
||||
opener: DialogOpener,
|
||||
) -> impl IntoView {
|
||||
view! {cx,
|
||||
{move ||
|
||||
if let Some(c) = company.get() {
|
||||
let update_company = create_server_action::<UpdateCompany>(cx);
|
||||
let upd_val = update_company.value();
|
||||
let validator = Validator::new(cx);
|
||||
view! {cx,
|
||||
<ActionForm
|
||||
on:submit=move |ev| {
|
||||
let act = UpdateCompany::from_event(&ev);
|
||||
if !act.is_err() {
|
||||
validator.check(&act.unwrap().company, &ev);
|
||||
}
|
||||
}
|
||||
action=update_company>
|
||||
<ModalDialog opener=opener title="Edit company">
|
||||
<ModalBody>
|
||||
<ServerErr result={upd_val} opener=opener/>
|
||||
<ValidationErr validator=validator />
|
||||
<input type="hidden" value=c.id() name="company[id]"/>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="nameWithTitle" class="form-label">"Name"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="nameWithTitle"
|
||||
class="form-control"
|
||||
placeholder="Enter Name"
|
||||
value=c.name
|
||||
name="company[name]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="street" class="form-label">"Street"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="street"
|
||||
class="form-control"
|
||||
placeholder="Enter Street"
|
||||
value=c.street
|
||||
name="company[street]"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<label for="houseNumber" class="form-label">"House number"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="houseNumber"
|
||||
class="form-control"
|
||||
placeholder="Enter House number"
|
||||
value=c.house_number
|
||||
name="company[house_number]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4 mb-3">
|
||||
<label for="zip" class="form-label">"ZIP code"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="zip"
|
||||
class="form-control"
|
||||
placeholder="Enter ZIP code"
|
||||
value=c.zip_code
|
||||
name="company[zip_code]"
|
||||
/>
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="city" class="form-label">"City"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="city"
|
||||
class="form-control"
|
||||
placeholder="Enter City"
|
||||
value=c.city
|
||||
name="company[city]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal" on:click=move |_| opener.hide()>
|
||||
{trl(cx, "Close")}
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{trl(cx, "Save changes")}
|
||||
</button>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ActionForm>
|
||||
let update_company = create_server_action::<UpdateCompany>();
|
||||
let upd_val = update_company.value();
|
||||
let validator = Validator::new();
|
||||
|
||||
view! {
|
||||
<ActionForm
|
||||
on:submit=move |ev| {
|
||||
let act = UpdateCompany::from_event(&ev);
|
||||
if !act.is_err() {
|
||||
validator.check(&act.unwrap().company, &ev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view! {cx,
|
||||
<DlgNotLoaded opener=opener title="Edit company" />
|
||||
}
|
||||
}
|
||||
}
|
||||
action=update_company>
|
||||
<ModalDialog opener=opener title="Edit company">
|
||||
<ModalBody>
|
||||
<ServerErr result={upd_val} opener=opener/>
|
||||
<ValidationErr validator=validator />
|
||||
<input type="hidden" value={move || company.get().id()} name="company[id]"/>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="nameWithTitle" class="form-label">"Name"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="nameWithTitle"
|
||||
class="form-control"
|
||||
placeholder="Enter Name"
|
||||
value={move || company.get().name}
|
||||
name="company[name]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="street" class="form-label">"Street"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="street"
|
||||
class="form-control"
|
||||
placeholder="Enter Street"
|
||||
value={move || company.get().street}
|
||||
name="company[street]"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<label for="houseNumber" class="form-label">"House number"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="houseNumber"
|
||||
class="form-control"
|
||||
placeholder="Enter House number"
|
||||
value={move || company.get().house_number}
|
||||
name="company[house_number]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4 mb-3">
|
||||
<label for="zip" class="form-label">"ZIP code"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="zip"
|
||||
class="form-control"
|
||||
placeholder="Enter ZIP code"
|
||||
value={move || company.get().zip_code}
|
||||
name="company[zip_code]"
|
||||
/>
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="city" class="form-label">"City"</label>
|
||||
<input
|
||||
type="text"
|
||||
id="city"
|
||||
class="form-control"
|
||||
placeholder="Enter City"
|
||||
value={move || company.get().city}
|
||||
name="company[city]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal" on:click=move |_| opener.hide()>
|
||||
{trl("Close")}
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{trl("Save changes")}
|
||||
</button>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ActionForm>
|
||||
}
|
||||
}
|
||||
|
||||
+12
-11
@@ -1,32 +1,33 @@
|
||||
use leptos::*;
|
||||
use serde::de::Unexpected::Option;
|
||||
use crate::backend::company::get_company;
|
||||
use crate::backend::data::Company;
|
||||
use crate::components::modal_box::DialogOpener;
|
||||
use crate::locales::trl;
|
||||
use crate::pages::company_edit::CompanyEdit;
|
||||
|
||||
#[component]
|
||||
pub fn CompanyInfo(cx: Scope) -> impl IntoView {
|
||||
let editor = DialogOpener::new(cx);
|
||||
let company = create_resource(cx, move|| editor.visible(), move |_| { get_company(cx) });
|
||||
let (cmp, set_cmp) = create_signal(cx, None);
|
||||
pub fn CompanyInfo() -> impl IntoView {
|
||||
let editor = DialogOpener::new();
|
||||
let company = create_resource(move|| editor.visible(), move |_| { get_company() });
|
||||
let (cmp, set_cmp) = create_signal(Company::default());
|
||||
|
||||
view! {cx,
|
||||
view! {
|
||||
<CompanyEdit company={cmp} opener=editor/>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><i class="bx bx-buildings"></i>" "{trl(cx, "Company info")}</h5>
|
||||
<h5 class="card-title"><i class="bx bx-buildings"></i>" "{trl("Company info")}</h5>
|
||||
<p class="card-text">
|
||||
<Transition fallback=move || view! {cx, <p>{trl(cx, "Loading...")}</p> }>
|
||||
<Transition fallback=move || view! {<p>{trl("Loading...")}</p> }>
|
||||
{move || {
|
||||
company.read(cx).map(|c| match c {
|
||||
Err(e) => {view! {cx, <p>{trl(cx, "Error loading data")}</p>
|
||||
company.read().map(|c| match c {
|
||||
Err(e) => {view! {<p>{trl("Error loading data")}</p>
|
||||
<p>{e.to_string()}</p>
|
||||
}}
|
||||
Ok(c) => {
|
||||
set_cmp.update(|cmp| *cmp = Some(c.clone()));
|
||||
set_cmp.update(|cmp| *cmp = c.clone());
|
||||
view! {
|
||||
cx, <p><b>{c.name}</b></p>
|
||||
<p><b>{c.name}</b></p>
|
||||
<p>{c.street}" "{c.house_number}<br/>
|
||||
{c.zip_code}" "{c.city}
|
||||
</p>
|
||||
|
||||
@@ -5,21 +5,21 @@ use crate::locales::trl;
|
||||
|
||||
/// Renders the home page of your application.
|
||||
#[component]
|
||||
pub fn HomePage(cx: Scope) -> impl IntoView {
|
||||
pub fn HomePage() -> impl IntoView {
|
||||
// Creates a reactive value to update the button
|
||||
let (count, set_count) = create_signal(cx, 0);
|
||||
let (count, set_count) = create_signal(0);
|
||||
let on_click = move |_| set_count.update(|count| *count += 1);
|
||||
|
||||
let dialog = DialogOpener::new(cx);
|
||||
let dialog = DialogOpener::new();
|
||||
|
||||
//let (dialog, set_dialog) = create_signal(cx, false);
|
||||
//let (dialog, set_dialog) = create_signal(false);
|
||||
//let on_dialog = move |_| dialog.set_visible.update(|dialog| {*dialog = true});
|
||||
|
||||
//let pok = use_context::<Request>(cx);
|
||||
//let pok = use_context::<Request>();
|
||||
//log!("{:?}", pok);
|
||||
|
||||
|
||||
view! { cx,
|
||||
view! {
|
||||
<ModalDialog opener={dialog} title="Titulek">
|
||||
<ModalBody>
|
||||
<div class="row">
|
||||
@@ -67,14 +67,14 @@ pub fn HomePage(cx: Scope) -> impl IntoView {
|
||||
<button on:click=move |_| dialog.show()>"Dialog"</button>
|
||||
<button on:click=move |_| {
|
||||
spawn_local(async move {
|
||||
set_session(cx).await;
|
||||
set_session().await;
|
||||
});
|
||||
}>"Session"</button>
|
||||
<button on:click=move |_| {
|
||||
spawn_local(async move {
|
||||
get_session(cx).await;
|
||||
get_session().await;
|
||||
});
|
||||
}>"Session get"</button>
|
||||
<p>{trl(cx, "testik!")}</p>
|
||||
<p>{trl("testik!")}</p>
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ use crate::locales::trl;
|
||||
use crate::pages::company_info::CompanyInfo;
|
||||
|
||||
#[component]
|
||||
pub fn Settings(cx: Scope) -> impl IntoView {
|
||||
view! {cx,
|
||||
<h1>{trl(cx, "Settings")}</h1>
|
||||
pub fn Settings() -> impl IntoView {
|
||||
view! {
|
||||
<h1>{trl("Settings")}</h1>
|
||||
<div class="row mb-5">
|
||||
<div class="col-md-6 col-lg-4 mb-3">
|
||||
<CompanyInfo/>
|
||||
|
||||
+8
-6
@@ -1,14 +1,15 @@
|
||||
use leptos::*;
|
||||
|
||||
#[server(SetSession, "/api", "Url", "set_session")]
|
||||
pub async fn set_session(cx: Scope) -> Result<(), ServerFnError> {
|
||||
pub async fn set_session() -> Result<(), ServerFnError> {
|
||||
use leptos_actix::extract;
|
||||
use actix_session::*;
|
||||
use actix_web::web::Data;
|
||||
use leptos::logging::log;
|
||||
//use crate::DataPok;
|
||||
|
||||
extract(cx, |session: Session| async move {
|
||||
leptos::log!("extract");
|
||||
extract(|session: Session| async move {
|
||||
log!("extract");
|
||||
let pok = session.insert("user", "uzivatel");
|
||||
log!("{pok:?}");
|
||||
}).await
|
||||
@@ -17,12 +18,13 @@ pub async fn set_session(cx: Scope) -> Result<(), ServerFnError> {
|
||||
}
|
||||
|
||||
#[server(GetSession, "/api")]
|
||||
pub async fn get_session(cx: Scope) -> Result<(), ServerFnError> {
|
||||
pub async fn get_session() -> Result<(), ServerFnError> {
|
||||
use leptos_actix::extract;
|
||||
use actix_session::*;
|
||||
use leptos::logging::log;
|
||||
|
||||
extract(cx, |session: Session| async move {
|
||||
leptos::log!("extract");
|
||||
extract(|session: Session| async move {
|
||||
log!("extract");
|
||||
let pok = session.get::<String>("user");
|
||||
log!("{pok:?}");
|
||||
}).await
|
||||
|
||||
+4
-4
@@ -12,10 +12,10 @@ pub struct Validator {
|
||||
}
|
||||
|
||||
impl Validator {
|
||||
pub fn new(cx: Scope) -> Self {
|
||||
let (valid, set_valid) = create_signal(cx, true);
|
||||
let (message, set_message) = create_signal(cx, None);
|
||||
let (messages, set_messages) = create_signal(cx, None);
|
||||
pub fn new() -> Self {
|
||||
let (valid, set_valid) = create_signal(true);
|
||||
let (message, set_message) = create_signal(None);
|
||||
let (messages, set_messages) = create_signal(None);
|
||||
Self {
|
||||
message,
|
||||
set_message,
|
||||
|
||||
Reference in New Issue
Block a user