Fix change page
This commit is contained in:
parent
45ce1e89f6
commit
19115f0dd9
75
Cargo.lock
generated
75
Cargo.lock
generated
@ -1564,6 +1564,8 @@ dependencies = [
|
||||
"libc",
|
||||
"libgit2-sys",
|
||||
"log",
|
||||
"openssl-probe",
|
||||
"openssl-sys",
|
||||
"url",
|
||||
]
|
||||
|
||||
@ -2047,10 +2049,26 @@ checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libssh2-sys",
|
||||
"libz-sys",
|
||||
"openssl-sys",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libssh2-sys"
|
||||
version = "0.2.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libz-sys",
|
||||
"openssl-sys",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.6"
|
||||
@ -2201,6 +2219,15 @@ dependencies = [
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minidom"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "332592c2149fc7dd40a64fc9ef6f0d65607284b474cef9817d1fc8c7e7b3608e"
|
||||
dependencies = [
|
||||
"quick-xml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
@ -2775,6 +2802,15 @@ version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.18"
|
||||
@ -3164,6 +3200,42 @@ dependencies = [
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "seed"
|
||||
version = "0.9.1"
|
||||
source = "git+https://github.com/seed-rs/seed#689055ef4f466f28dca621c23f5e2df7438bd1bc"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"cookie",
|
||||
"dbg",
|
||||
"enclose",
|
||||
"futures",
|
||||
"getrandom",
|
||||
"gloo-file",
|
||||
"gloo-timers",
|
||||
"gloo-utils",
|
||||
"indexmap",
|
||||
"js-sys",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"uuid",
|
||||
"version_check 0.9.4",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "seed_heroicons"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/mh84/seed_heroicons.git#32569ac5ba9adcffb168fbdaac8b258e99e73d86"
|
||||
dependencies = [
|
||||
"git2",
|
||||
"minidom",
|
||||
"seed 0.9.1 (git+https://github.com/seed-rs/seed)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
@ -4278,7 +4350,8 @@ dependencies = [
|
||||
"model",
|
||||
"pure-rust-locales",
|
||||
"rusty-money",
|
||||
"seed",
|
||||
"seed 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"seed_heroicons",
|
||||
"serde",
|
||||
"serde-wasm-bindgen",
|
||||
"serde_json",
|
||||
|
@ -10,6 +10,7 @@ crate-type = ["cdylib"]
|
||||
model = { path = "../shared/model", features = ["dummy"] }
|
||||
|
||||
seed = { version = "0.9.1", features = [] }
|
||||
seed_heroicons = { git = "https://github.com/mh84/seed_heroicons.git" }
|
||||
|
||||
chrono = { version = "*" }
|
||||
gloo-timers = { version = "*", features = ["futures"] }
|
||||
|
@ -42,6 +42,22 @@ macro_rules! fetch_page {
|
||||
_ => return,
|
||||
}
|
||||
}};
|
||||
(public page $page: expr, $page_name: ident, $ret: expr) => {{
|
||||
let p = match $page {
|
||||
crate::pages::Page::Public(p) => p,
|
||||
_ => {
|
||||
*$page = $ret;
|
||||
return;
|
||||
}
|
||||
};
|
||||
match p {
|
||||
crate::pages::PublicPage::$page_name(p) => p,
|
||||
_ => {
|
||||
*$page = $ret;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
|
||||
@ -81,7 +97,7 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg::UrlChanged(subs::UrlChanged(url)) => model.page.page_changed(url),
|
||||
Msg::UrlChanged(subs::UrlChanged(url)) => model.page.page_changed(url, orders),
|
||||
Msg::Public(pages::public::Msg::Listing(msg)) => {
|
||||
let page = fetch_page!(public model, Listing);
|
||||
pages::public::listing::update(msg, page, &mut orders.proxy(proxy_public_listing));
|
||||
|
@ -56,18 +56,18 @@ impl Page {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_changed(&mut self, url: Url) {
|
||||
pub fn page_changed(&mut self, url: Url, orders: &mut impl Orders<Msg>) {
|
||||
match url.clone().remaining_path_parts().as_slice() {
|
||||
[] => {
|
||||
let page = crate::fetch_page!(public page self, Listing);
|
||||
let page = crate::fetch_page!(public page self, Listing, Page::init(url, orders));
|
||||
public::listing::page_changed(url, page);
|
||||
}
|
||||
["products", _rest @ ..] => {
|
||||
let page = crate::fetch_page!(public page self, Listing);
|
||||
let page = crate::fetch_page!(public page self, Listing, Page::init(url, orders));
|
||||
public::listing::page_changed(url, page);
|
||||
}
|
||||
["page", ..] => {
|
||||
let page = crate::fetch_page!(public page self, Product);
|
||||
["product", ..] => {
|
||||
let page = crate::fetch_page!(public page self, Product, Page::init(url, orders));
|
||||
public::product::page_changed(url, page);
|
||||
}
|
||||
["admin"] => {}
|
||||
|
@ -1,6 +1,5 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use model::api::Product;
|
||||
use seed::app::Orders;
|
||||
use seed::prelude::*;
|
||||
use seed::*;
|
||||
|
@ -49,6 +49,13 @@ pub fn view(model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(idx, img)| image(idx, img));
|
||||
|
||||
let description = product
|
||||
.long_description
|
||||
.as_str()
|
||||
.split('\n')
|
||||
.map(|s| div![s]);
|
||||
|
||||
let content = div![
|
||||
C!["max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mt-6"],
|
||||
div![
|
||||
@ -65,10 +72,12 @@ pub fn view(model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
|
||||
h2![
|
||||
C!["mb-2 leading-tight tracking-tight font-bold text-gray-800 text-2xl md:text-3xl"],
|
||||
product.name.as_str()
|
||||
]
|
||||
],
|
||||
div![description]
|
||||
]
|
||||
]
|
||||
].map_msg(map_to_global);
|
||||
|
||||
div![
|
||||
crate::shared::view::public_navbar(model),
|
||||
super::layout::view(model.url.clone(), content, None)
|
||||
|
Loading…
Reference in New Issue
Block a user