tetratto/crates/app/src/public/html/stacks/list.lisp
2025-08-11 20:21:05 -04:00

78 lines
2.5 KiB
Common Lisp

(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "My stacks - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
(main
("class" "flex flex_col gap_2")
(text "{{ macros::timelines_nav(selected=\"stacks\") }} {% if user -%}")
(div
("class" "card_nest")
(div
("class" "card small")
(b
(text "{{ text \"stacks:label.create_new\" }}")))
(form
("class" "card flex flex_col gap_2")
("onsubmit" "create_stack_from_form(event)")
(div
("class" "flex flex_col gap_1")
(label
("for" "name")
(text "{{ text \"communities:label.name\" }}"))
(input
("type" "text")
("name" "name")
("id" "name")
("placeholder" "name")
("required" "")
("minlength" "2")
("maxlength" "32")))
(button
(str (text "communities:action.create")))))
(text "{%- endif %}")
(div
("class" "card_nest w_full")
(div
("class" "card small flex items_center justify_between gap_2")
(div
("class" "flex items_center gap_2")
(text "{{ icon \"layers\" }}")
(span
(text "{{ text \"stacks:label.my_stacks\" }}"))))
(div
("class" "card flex flex_col gap_2")
(text "{% for item in list %}")
(text "{{ components::stack_listing(stack=item) }}")
(text "{% endfor %}"))))
(script
(text "async function create_stack_from_form(e) {
e.preventDefault();
await trigger(\"atto::debounce\", [\"stacks::create\"]);
fetch(\"/api/v1/stacks\", {
method: \"POST\",
headers: {
\"Content-Type\": \"application/json\",
},
body: JSON.stringify({
name: e.target.name.value,
}),
})
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
if (res.ok) {
setTimeout(() => {
window.location.href = `/stacks/${res.payload}`;
}, 100);
}
});
}"))
(text "{% endblock %}")