1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// rocie - An enterprise grocery management system - Web app
//
// Copyright (C) 2026 Benedikt Peetz <benedikt.peetz@b-peetz.de>
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This file is part of Rocie.
//
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
pub mod associate_barcode;
pub mod buy;
pub mod create_product;
pub mod create_product_parent;
pub mod create_recipe;
pub mod home;
pub mod inventory;
pub mod login;
pub mod not_found;
pub mod product;
pub mod products;
pub mod provision;
pub mod recipe;
pub mod recipies;
pub mod units;
macro_rules! mk_render_parents {
(
self = $self:ident,
parent_type = $parent_type:ty,
item_type = $item_type:ty,
value_renderer = $value_renderer:ident,
under_parent_fetcher = $under_parent_fetcher:ident,
indirect_fetcher = $indirect_fetcher:ident,
direct_fetcher = $direct_fetcher:ident $(,)?
) => {
fn $self(
parents: Option<Vec<$parent_type>>,
toplevel_items: Option<Vec<$item_type>>,
) -> impl IntoView {
use leptos::prelude::IntoAny;
view! {
{
parents.map(|parents| {
parents
.into_iter()
.map(|parent| {
view! {
<li>
<details>
<summary>{parent.name} {" ("} {
AsyncFetch! {
@map_error_in_producer
fetcher = $indirect_fetcher(parent.id),
producer = |products| {products.len()}
}
} {")"}</summary>
<ul class="flex flex-col p-2">
{
AsyncFetch! {
@map_error_in_producer
fetcher = $under_parent_fetcher(parent.id),
producer = |val| $self(val, None)
}
}
{
AsyncFetch! {
@map_error_in_producer
fetcher = $direct_fetcher(parent.id),
producer = $value_renderer
}
}
</ul>
</details>
</li>
}
.into_any()
})
.collect::<Vec<_>>()
})
}
{
if let Some(toplevel_items) = toplevel_items {
$value_renderer(toplevel_items).into_any()
} else {
().into_any()
}
}
}
}
};
}
use mk_render_parents;
|