16#include <glaze/glaze.hpp>
29template <morph::forms::FixedString Label, morph::forms::FixedString ScreenId>
33 [[nodiscard]]
static constexpr std::string_view
label() noexcept {
return Label.view(); }
37 [[nodiscard]]
static constexpr std::string_view
screen() noexcept {
return ScreenId.view(); }
43template <morph::forms::FixedString Id,
typename Action>
47 [[nodiscard]]
static constexpr std::string_view
id() noexcept {
return Id.view(); }
51 [[nodiscard]]
static constexpr std::string_view
kind() noexcept {
return "form"; }
55 [[nodiscard]]
static constexpr std::string_view
ref() noexcept {
56 return ::morph::model::ActionTraits<Action>::typeId();
63template <morph::forms::FixedString Id,
typename Wizard>
67 [[nodiscard]]
static constexpr std::string_view
id() noexcept {
return Id.view(); }
71 [[nodiscard]]
static constexpr std::string_view
kind() noexcept {
return "wizard"; }
75 [[nodiscard]]
static constexpr std::string_view
ref() noexcept {
76 return ::morph::flows::WizardTraits<Wizard>::typeId();
92template <morph::forms::FixedString Title,
typename Menu,
typename Screens>
102 [[nodiscard]]
static constexpr std::string_view
title() noexcept {
return Title.view(); }
123template <
typename AppT>
125 glz::generic_u64 dom{};
126 dom[
"app-title"] = std::string{AppT::title()};
128 glz::generic_u64::array_t menu{};
129 ::morph::forms::detail::forEachTupleElement<typename AppT::menu>([&]<
typename Entry, std::size_t I>() {
130 static_cast<void>(I);
131 glz::generic_u64 entry{};
132 entry[
"label"] = std::string{Entry::label()};
133 entry[
"screen"] = std::string{Entry::screen()};
134 menu.emplace_back(std::move(entry));
136 dom[
"app-menu"] = menu;
138 auto& screensNode = dom[
"app-screens"];
139 ::morph::forms::detail::forEachTupleElement<typename AppT::screens>([&]<
typename S, std::size_t I>() {
140 static_cast<void>(I);
141 auto& screenNode = screensNode[std::string{S::id()}];
142 screenNode[
"kind"] = std::string{S::kind()};
143 screenNode[
"ref"] = std::string{S::ref()};
146 return glz::write_json(dom).value_or(std::string{});
159#define BRIDGE_REGISTER_APP(A, NAME) \
161 struct morph::app::AppTraits<A> { \
162 static constexpr std::string_view typeId() noexcept { return NAME; } \
std::string appSchemaJson()
Generates the app-* JSON document for app-shell type AppT.
Multi-step wizards: an ordered sequence of registered actions that share a "flow draft" spanning the ...
Machinery shared by the two form session types: morph::flows::FlowSession (ordered wizard steps) and ...
Traits specialisation mapping an App type to its string type-id.
The app-shell descriptor: a title, an ordered menu, and the screens it routes to.
static constexpr std::string_view title() noexcept
The application's display title.
Menu menu
Tuple of this app's ordered MenuEntry<...> types.
Screens screens
Tuple of this app's screen descriptor types.
A screen backed by a registered morph::flows::Wizard.
static constexpr std::string_view ref() noexcept
The referenced wizard's registered type-id.
static constexpr std::string_view id() noexcept
The screen's id.
static constexpr std::string_view kind() noexcept
The screen's kind, for the app-screens[id].kind key.