morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
field_model.hpp File Reference

FormModel: the immutable runtime model of one action's form, read from the schema JSON schemaJson<A>() emits (or any document in that vocabulary). More...

#include <algorithm>
#include <cmath>
#include <compare>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <iterator>
#include <map>
#include <optional>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "../../util/rational.hpp"
#include "../blank_as.hpp"
#include "../layout.hpp"
#include "detail/text.hpp"
#include "rules.hpp"

Go to the source code of this file.

Classes

struct  morph::forms::UnitOption
 One unit a Quantity can be entered in; the first of a field's units is canonical. More...
struct  morph::forms::ChoiceOption
 One selectable value of an Enum or a Choice. More...
struct  morph::forms::ChoiceSpec
 Where a Choice's options come from (x-optionsAction and its companions). More...
struct  morph::forms::FieldSpec
 Everything the engine knows about one field, from its schema property. More...
struct  morph::forms::FieldOverlay
 What a document (or an application) changes about one top-level field before the session is built: a form node's fields entry (spec 6 ยง10). An unset member keeps the schema's. More...
struct  morph::forms::FieldGroupSpec
 One x-layout group, or the implicit group of the fields no group names. More...
class  morph::forms::FormModel
 The immutable runtime model of one action's form. More...

Typedefs

using morph::forms::FieldOverlays = std::map<std::string, FieldOverlay, std::less<>>
 The overlays of a form's fields, by wire name.

Enumerations

enum class  morph::forms::FieldKind : std::uint8_t {
  Text , Multiline , Integer , Number ,
  Decimal , Quantity , Boolean , Enum ,
  Choice , DateTime , Date , EpochDateTime ,
  EpochDate , Slider , Array , Object ,
  ObjectArray
}
 The control a field gets, which the JSON type alone does not say. More...
enum class  morph::forms::SubmitMode : std::uint8_t { Automatic , Explicit }
 When a form submits. More...

Functions

constexpr std::string_view morph::forms::fieldKindName (FieldKind kind) noexcept
 The stable name of a field kind (what Overrides::byKind documents and tests print).

Variables

constexpr std::size_t morph::forms::kMaxNestingDepth = 4
 How many object levels below the action a schema is described; a deeper member is FieldSpec::truncated.

Detailed Description

FormModel: the immutable runtime model of one action's form, read from the schema JSON schemaJson<A>() emits (or any document in that vocabulary).

Specified in docs/spec/forms/engine.md, "The field model".

Definition in file field_model.hpp.

Typedef Documentation

◆ FieldOverlays

using morph::forms::FieldOverlays = std::map<std::string, FieldOverlay, std::less<>>

The overlays of a form's fields, by wire name.

Definition at line 264 of file field_model.hpp.

Enumeration Type Documentation

◆ FieldKind

enum class morph::forms::FieldKind : std::uint8_t
strong

The control a field gets, which the JSON type alone does not say.

Enumerator
Text 

A string.

Multiline 

A string edited over several lines (x-widget: textarea).

Integer 

An integer of any width; every digit is kept.

Number 

A plain JSON number (a double/float member).

Decimal 

An exact {num, den, dp} with a declared precision and no unit.

Quantity 

An exact {num, den, dp} in a unit, with optional convertible alternatives.

Boolean 

true / false.

Enum 

A closed set the schema states.

Choice 

A set fetched by executing an options action.

DateTime 

An instant, entered in the display zone, sent as ISO-8601 UTC.

Date 

A calendar date, YYYY-MM-DD.

EpochDateTime 

An instant as int64 seconds since the epoch (UTC): x-widget: epochSeconds on an integer.

EpochDate 

A calendar date as int64 days since the epoch: x-widget: epochDays on an integer.

Slider 

A number on a track (x-widget: slider with x-min/x-max).

Array 

A list of scalars, entered comma-separated.

Object 

A nested object.

ObjectArray 

A list of nested objects.

Definition at line 36 of file field_model.hpp.

◆ SubmitMode

enum class morph::forms::SubmitMode : std::uint8_t
strong

When a form submits.

Enumerator
Automatic 

Whenever it becomes ready with a changed body (no x-submitMode).

Explicit 

Only on FormSession::submit() (x-submitMode: explicit).

Definition at line 103 of file field_model.hpp.

Function Documentation

◆ fieldKindName()

std::string_view morph::forms::fieldKindName ( FieldKind kind)
nodiscardconstexprnoexcept

The stable name of a field kind (what Overrides::byKind documents and tests print).

Parameters
kindThe kind.
Returns
"text", "multiline", "integer", "number", "decimal", "quantity", "boolean", "enum", "choice", "datetime", "date", "epochDateTime", "epochDate", "slider", "array", "object" or "objectArray".

Definition at line 61 of file field_model.hpp.

Variable Documentation

◆ kMaxNestingDepth

std::size_t morph::forms::kMaxNestingDepth = 4
inlineconstexpr

How many object levels below the action a schema is described; a deeper member is FieldSpec::truncated.

Definition at line 110 of file field_model.hpp.