morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::author::Scope Class Reference

The screen's own scope: its declarations, params, lifecycle keys, components and customization points. More...

#include <author.hpp>

Inheritance diagram for morph::ui::author::Scope:
morph::ui::author::DeclScope

Public Member Functions

template<typename T>
Handle< T > param (std::string const &name)
 A typed param, set by navigation.
void title (AnyHandle const &title)
 The screen's title.
void identity (AnyHandle const &identity)
 The screen's identity: two screens with equal identities are one.
void dirty (AnyHandle const &dirty)
 Whether the screen has unsaved changes.
void subtitle (AnyHandle const &subtitle)
 The head's line under the title.
void status (HeadBadgeOptions const &badge)
 Appends a status badge to the head.
void action (ActionButtonOptions const &action)
 Appends an action to the head, run in the screen scope.
void onMount (Commands const &commands)
 Commands run when the screen mounts.
void onUnmount (Commands const &commands)
 Commands run when the screen unmounts.
void onClose (Commands const &commands)
 Commands run when the screen is asked to close; cancelClose() keeps it open.
void onSave (Commands const &commands)
 Commands run when the host asks the screen to save.
void onBackendChange (Commands const &commands)
 Commands run after a backend switch.
void key (std::string const &chord, Commands const &commands)
 A screen-wide key binding.
void showErrors (ShowErrors when)
 When the screen's element errors show.
void prefetch (QueryRef const &query)
 A query started before the screen mounts; its body reads only params.
ComponentRef component (std::string const &name, ComponentOptions const &options)
 A custom or host component.
Point columnsPoint (std::string const &name, Element const &table)
 A columns point: the user reorders, hides and resizes a table's columns.
Point arrangePoint (std::string const &name, Element const &container)
 An arrange point: the user reorders and hides the children of a column or row, each of which has an id.
Point choicePoint (std::string const &name, std::vector< std::string > const &options, std::string const &fallback={})
 A choice point: one of a list of options.
template<typename T>
Point valuePoint (std::string const &name, Value const &fallback={})
 A value point: one typed setting.
Point point (std::string const &name, std::string const &kind)
 A layout or saved point.
Json document (std::string const &documentId, Node const &view) const
 The document's JSON with a view.
Public Member Functions inherited from morph::ui::author::DeclScope
 DeclScope ()=default
 An empty scope.
template<typename Model>
ModelHandle< Model > model (std::string const &alias, ModelOptions const &options={})
 A model alias.
template<typename T>
Handle< T > state (std::string const &name)
 State with a declared type and no initial value; it starts null.
template<typename T>
Handle< T > state (std::string const &name, Handle< T > const &init)
 State initialised from an expression; its type is T's.
template<typename L>
requires detail::Literal<L>
Handle< detail::LiteralT< L > > state (std::string const &name, L const &init)
 State initialised from a constant; its type is the constant's.
template<typename T>
Handle< T > let (std::string const &name, Handle< T > const &value)
 A derived value (let).
template<typename Action, typename Model>
requires Runs<Model, Action>
QueryHandle< Action > query (std::string const &name, ModelHandle< Model > const &model, Body< Action > const &body={}, QueryOptions const &options={})
 A query (spec 5 §5).
template<typename Action, typename Model>
requires Runs<Model, Action>
QueryHandle< Action, Action > evaluate (std::string const &name, ModelHandle< Model > const &model, Body< Action > const &body={}, QueryOptions const &options={})
 A query that evaluates an action without running it: the server returns its calculated fields and field errors (spec 5 §7).
template<typename Action, typename Model>
requires Runs<Model, Action>
MutationHandle< Action > mutation (std::string const &name, ModelHandle< Model > const &model, MutationOptions< Action > const &options={})
 A mutation (spec 5 §5).
void watch (AnyHandle const &watched, Commands const &commands, Source source=Source::Any)
 A cascade: commands that run when a value changes (spec 5 §6).
void check (CheckOptions const &options)
 A validation across elements (spec 5 §6).
bool empty () const
 Whether the scope declares nothing.
void writeTo (Json &out) const
 Writes the declarations into a document or a "scope" object, in the document's order.
CatalogFacts const & facts () const noexcept
 The catalog facts of the models and actions the scope names.

Additional Inherited Members

Protected Member Functions inherited from morph::ui::author::DeclScope
CatalogFacts & recordedFacts () noexcept
 The catalog facts, for a scope that records more.

Detailed Description

The screen's own scope: its declarations, params, lifecycle keys, components and customization points.

Definition at line 2494 of file author.hpp.

Member Function Documentation

◆ param()

template<typename T>
Handle< T > morph::ui::author::Scope::param ( std::string const & name)
inline

A typed param, set by navigation.

Template Parameters
TThe param's type.
Parameters
nameThe param's name.
Returns
The read of the param.

Definition at line 2501 of file author.hpp.

◆ title()

void morph::ui::author::Scope::title ( AnyHandle const & title)
inline

The screen's title.

Parameters
titleThe expression.

Definition at line 2508 of file author.hpp.

◆ identity()

void morph::ui::author::Scope::identity ( AnyHandle const & identity)
inline

The screen's identity: two screens with equal identities are one.

Parameters
identityThe expression.

Definition at line 2512 of file author.hpp.

◆ dirty()

void morph::ui::author::Scope::dirty ( AnyHandle const & dirty)
inline

Whether the screen has unsaved changes.

Parameters
dirtyThe condition.

Definition at line 2516 of file author.hpp.

◆ subtitle()

void morph::ui::author::Scope::subtitle ( AnyHandle const & subtitle)
inline

The head's line under the title.

Parameters
subtitleThe expression.

Definition at line 2520 of file author.hpp.

◆ status()

void morph::ui::author::Scope::status ( HeadBadgeOptions const & badge)
inline

Appends a status badge to the head.

Parameters
badgeThe badge.

Definition at line 2524 of file author.hpp.

◆ action()

void morph::ui::author::Scope::action ( ActionButtonOptions const & action)
inline

Appends an action to the head, run in the screen scope.

Parameters
actionThe action; its id is unique among the head's actions.

Definition at line 2528 of file author.hpp.

◆ onMount()

void morph::ui::author::Scope::onMount ( Commands const & commands)
inline

Commands run when the screen mounts.

Parameters
commandsThe commands.

Definition at line 2532 of file author.hpp.

◆ onUnmount()

void morph::ui::author::Scope::onUnmount ( Commands const & commands)
inline

Commands run when the screen unmounts.

Parameters
commandsThe commands.

Definition at line 2536 of file author.hpp.

◆ onClose()

void morph::ui::author::Scope::onClose ( Commands const & commands)
inline

Commands run when the screen is asked to close; cancelClose() keeps it open.

Parameters
commandsThe commands.

Definition at line 2540 of file author.hpp.

◆ onSave()

void morph::ui::author::Scope::onSave ( Commands const & commands)
inline

Commands run when the host asks the screen to save.

Parameters
commandsThe commands.

Definition at line 2544 of file author.hpp.

◆ onBackendChange()

void morph::ui::author::Scope::onBackendChange ( Commands const & commands)
inline

Commands run after a backend switch.

Parameters
commandsThe commands.

Definition at line 2548 of file author.hpp.

◆ key()

void morph::ui::author::Scope::key ( std::string const & chord,
Commands const & commands )
inline

A screen-wide key binding.

Parameters
chordThe chord.
commandsThe commands.

Definition at line 2553 of file author.hpp.

◆ showErrors()

void morph::ui::author::Scope::showErrors ( ShowErrors when)
inline

When the screen's element errors show.

Parameters
whenThe policy.

Definition at line 2557 of file author.hpp.

◆ prefetch()

void morph::ui::author::Scope::prefetch ( QueryRef const & query)
inline

A query started before the screen mounts; its body reads only params.

Parameters
queryThe query.

Definition at line 2561 of file author.hpp.

◆ component()

ComponentRef morph::ui::author::Scope::component ( std::string const & name,
ComponentOptions const & options )
inline

A custom or host component.

Parameters
nameThe component's name.
optionsThe component.
Returns
The reference custom nodes name.

Definition at line 2567 of file author.hpp.

◆ columnsPoint()

Point morph::ui::author::Scope::columnsPoint ( std::string const & name,
Element const & table )
inline

A columns point: the user reorders, hides and resizes a table's columns.

Parameters
nameThe point's name.
tableThe table.
Returns
The point.

Definition at line 2601 of file author.hpp.

◆ arrangePoint()

Point morph::ui::author::Scope::arrangePoint ( std::string const & name,
Element const & container )
inline

An arrange point: the user reorders and hides the children of a column or row, each of which has an id.

Parameters
nameThe point's name.
containerThe column or row.
Returns
The point.

Definition at line 2613 of file author.hpp.

◆ choicePoint()

Point morph::ui::author::Scope::choicePoint ( std::string const & name,
std::vector< std::string > const & options,
std::string const & fallback = {} )
inline

A choice point: one of a list of options.

Parameters
nameThe point's name.
optionsThe options.
fallbackThe default; empty for none.
Returns
The point.

Definition at line 2625 of file author.hpp.

◆ valuePoint()

template<typename T>
Point morph::ui::author::Scope::valuePoint ( std::string const & name,
Value const & fallback = {} )
inline

A value point: one typed setting.

Template Parameters
TThe setting's type.
Parameters
nameThe point's name.
fallbackThe default.
Returns
The point.

Definition at line 2642 of file author.hpp.

◆ point()

Point morph::ui::author::Scope::point ( std::string const & name,
std::string const & kind )
inline

A layout or saved point.

Parameters
nameThe point's name.
kindlayout or saved.
Returns
The point.

Definition at line 2654 of file author.hpp.

◆ document()

Json morph::ui::author::Scope::document ( std::string const & documentId,
Node const & view ) const
inlinenodiscard

The document's JSON with a view.

Parameters
documentIdThe document id.
viewThe view.
Returns
The document.

Definition at line 2664 of file author.hpp.


The documentation for this class was generated from the following file: