|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
The immutable runtime model of one action's form. More...
#include <field_model.hpp>
Public Member Functions | |
| FormModel | withSubmitMode (SubmitMode mode) const |
| The same model with another submit mode: a document's submit choosing over x-submitMode. | |
| std::string_view | actionType () const noexcept |
| The action type the form submits. | |
| std::string_view | title () const noexcept |
| The schema's top-level title, or the action type. | |
| std::span< FieldSpec const > | fields () const noexcept |
| The top-level fields, in x-order. | |
| std::span< FieldGroupSpec const > | groups () const noexcept |
| The layout groups: the declared x-layout groups, then an implicit group of the fields none names; without x-layout, one implicit group of every field. | |
| std::span< RuleExpr const > | rules () const noexcept |
| The parsed x-rules, in declaration order. | |
| SubmitMode | submitMode () const noexcept |
| When the form submits. | |
| FieldSpec const * | find (std::string_view name) const noexcept |
| A top-level field by wire name. | |
Static Public Member Functions | |
| static std::expected< FormModel, SchemaError > | fromSchema (std::string_view actionType, std::string_view schemaJson, FieldOverlays const &overlays={}) |
| Reads a schema document, with the overlays a document or an application states for its fields. | |
| template<class A> | |
| static FormModel | forAction () |
| The model of a registered action's own form: fromSchema over ActionTraits<A>::typeId() and schemaJson<A>(). | |
The immutable runtime model of one action's form.
Built from schema JSON by fromSchema; forAction<A>() (which the typed facade Form<A> uses) reads schemaJson<A>() through the same reader, so a typed and a runtime form of one action are the same model.
Definition at line 785 of file field_model.hpp.
|
inlinestaticnodiscard |
Reads a schema document, with the overlays a document or an application states for its fields.
omit, hidden, label, widget and blankAs are applied to the schema before it is read, so a widget overlay chooses the kind exactly as the schema's own x-widget would; unit and decimals are applied to the read field. An overlay naming a field the schema does not have is a SchemaError, as is a unit that is not one of a Quantity's units.
| actionType | The action type the form submits (the registered type id). |
| schemaJson | The schema, in the vocabulary schemaJson<A>() emits. |
| overlays | The overlays of top-level fields, by wire name. |
Definition at line 798 of file field_model.hpp.
|
inlinenodiscard |
The same model with another submit mode: a document's submit choosing over x-submitMode.
| mode | The mode. |
Definition at line 858 of file field_model.hpp.
|
staticnodiscard |
The model of a registered action's own form: fromSchema over ActionTraits<A>::typeId() and schemaJson<A>().
Declared here and defined in forms/engine/typed_form.hpp, the one engine header that includes the schema emitters; include that header to call it. The schema is compiled from A, so a reader error is a defect in the emitter or the engine, never bad input: it throws rather than returning an expected every caller would have to unwrap.
| A | The action type (registered with BRIDGE_REGISTER_ACTION or declared with BRIDGE_DECLARE_ACTION). |
| std::logic_error | naming the action id and the error's path and message when the engine cannot read the action's schema. |
Definition at line 33 of file typed_form.hpp.
|
inlinenodiscardnoexcept |
The action type the form submits.
Definition at line 881 of file field_model.hpp.
|
inlinenodiscardnoexcept |
The schema's top-level title, or the action type.
Definition at line 885 of file field_model.hpp.
|
inlinenodiscardnoexcept |
The top-level fields, in x-order.
Definition at line 889 of file field_model.hpp.
|
inlinenodiscardnoexcept |
The layout groups: the declared x-layout groups, then an implicit group of the fields none names; without x-layout, one implicit group of every field.
Definition at line 894 of file field_model.hpp.
|
inlinenodiscardnoexcept |
The parsed x-rules, in declaration order.
Definition at line 898 of file field_model.hpp.
|
inlinenodiscardnoexcept |
When the form submits.
Definition at line 902 of file field_model.hpp.
|
inlinenodiscardnoexcept |
A top-level field by wire name.
| name | The wire name. |
Definition at line 907 of file field_model.hpp.