Skip to main content

max / quasi

762 B · 37 lines History Blame Raw
1 #![allow(unused)]
2
3 use quasi_declare::declare;
4 use quasi_router::{Choice, Node};
5
6 struct Theme {
7 id: String,
8 name: String,
9 selected: bool,
10 }
11
12 fn chosen_theme(themes: &[Theme]) -> String {
13 themes
14 .iter()
15 .find(|theme| theme.selected)
16 .map(|theme| theme.id.clone())
17 .unwrap_or_default()
18 }
19
20 declare! {
21 shape picker(themes: &[Theme]) -> Node;
22
23 form put "/api/theme" awaiting {
24 submit "Save";
25 field Select "theme_id" "Theme" {
26 for theme in themes.iter() {
27 option Choice::new(theme.id.clone(), theme.name.clone()) {
28 chosen when theme.selected;
29 }
30 }
31 value chosen_theme(themes);
32 }
33 }
34 }
35
36 fn main() {}
37