The reactive state of one collection: the list, the table source, the actions, the confirm step and the row editor. A controller in the sense of docs/spec/reactive/control.md; it draws nothing.
More...
#include <collection.hpp>
|
| | CollectionSession (reactive::Runtime &runtime, CollectionModel model, SchemaLookup const &schemas, Submitter submit, ChoiceFetcher choices, FormSessionOptions options={}) |
|
| CollectionSession (CollectionSession const &)=delete |
|
CollectionSession & | operator= (CollectionSession const &)=delete |
|
| CollectionSession (CollectionSession &&)=delete |
|
CollectionSession & | operator= (CollectionSession &&)=delete |
| CollectionModel const & | model () const noexcept |
| | The view model.
|
| std::vector< CollectionRow > const & | rows () const |
| | The listed rows, from the last successful query, in the order the reply gave them. Tracked.
|
| std::shared_ptr< table::VectorSource > const & | source () const noexcept |
| | The rows as a table source, one column per v-columns entry: what a table engine sorts, filters and selects over. Replaced (a Reset) on every list reply. Owner-affine, like every DataSource.
|
| bool | loading () const |
| | Whether the list is loading. Tracked.
|
| std::exception_ptr | listError () const |
| | The list's last failure. Tracked.
|
| void | refresh () |
| | Reloads the list.
|
| void | fire (std::size_t action, std::string_view rowKey={}) |
| | Fires model().actions()[action], on rowKey for a row action. A confirm-guarded action waits in pendingConfirm() instead. While another action is in flight the call does nothing (the actions are one Exclusive mutation, and a view disables its buttons while actionPending()).
|
| std::optional< PendingConfirm > const & | pendingConfirm () const |
| | The action waiting for confirmation. Tracked.
|
| void | confirm () |
| | Runs the action waiting for confirmation, if any.
|
| void | cancelConfirm () |
| | Drops the action waiting for confirmation: nothing is sent.
|
| void | open (std::string_view rowKey) |
| | Opens the editor on a row, prefilled from the row action's bind entries with the row's exact values. A prefill replaces every field, so nothing typed for another row carries over. Programmatic, so nothing is submitted until the user edits.
|
| void | close () |
| | Closes the editor without submitting.
|
| std::optional< std::string > const & | openRow () const |
| | The row the editor is open on. Tracked.
|
| FormSession * | editor () const noexcept |
| | The row editor.
|
| bool | actionPending () const |
| | Whether an action is in flight. Tracked.
|
| std::exception_ptr | actionError () const |
| | The last action failure. Tracked.
|
The reactive state of one collection: the list, the table source, the actions, the confirm step and the row editor. A controller in the sense of docs/spec/reactive/control.md; it draws nothing.
Non-copyable and non-movable: replies and the editor point into it. Destroy a view of it before the session.
Definition at line 366 of file collection.hpp.
◆ CollectionSession()
- Parameters
-
| runtime | The runtime. Borrowed: it must outlive the session. |
| model | The view model. |
| schemas | Finds the row action's schema; an unknown or malformed one means the collection has no editor. |
| submit | Executes the query and every action. Required. |
| choices | Fetches the editor's Choice options; may be empty. |
| options | The editor's session options. |
- Exceptions
-
| std::invalid_argument | when submit is empty. |
Definition at line 375 of file collection.hpp.
◆ model()
◆ rows()
| std::vector< CollectionRow > const & morph::forms::CollectionSession::rows |
( |
| ) |
const |
|
inlinenodiscard |
The listed rows, from the last successful query, in the order the reply gave them. Tracked.
- Returns
- The rows.
Definition at line 418 of file collection.hpp.
◆ source()
| std::shared_ptr< table::VectorSource > const & morph::forms::CollectionSession::source |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
The rows as a table source, one column per v-columns entry: what a table engine sorts, filters and selects over. Replaced (a Reset) on every list reply. Owner-affine, like every DataSource.
- Returns
- The source.
Definition at line 423 of file collection.hpp.
◆ loading()
| bool morph::forms::CollectionSession::loading |
( |
| ) |
const |
|
inlinenodiscard |
Whether the list is loading. Tracked.
- Returns
- true while the query is in flight.
Definition at line 427 of file collection.hpp.
◆ listError()
| std::exception_ptr morph::forms::CollectionSession::listError |
( |
| ) |
const |
|
inlinenodiscard |
The list's last failure. Tracked.
- Returns
- The exception, or null.
Definition at line 431 of file collection.hpp.
◆ refresh()
| void morph::forms::CollectionSession::refresh |
( |
| ) |
|
|
inline |
◆ fire()
| void morph::forms::CollectionSession::fire |
( |
std::size_t | action, |
|
|
std::string_view | rowKey = {} ) |
|
inline |
Fires model().actions()[action], on rowKey for a row action. A confirm-guarded action waits in pendingConfirm() instead. While another action is in flight the call does nothing (the actions are one Exclusive mutation, and a view disables its buttons while actionPending()).
- Parameters
-
| action | Index into model().actions(). |
| rowKey | The row's exact key text, for a row action. |
- Exceptions
-
| std::out_of_range | for an index past the actions. |
Definition at line 442 of file collection.hpp.
◆ pendingConfirm()
| std::optional< PendingConfirm > const & morph::forms::CollectionSession::pendingConfirm |
( |
| ) |
const |
|
inlinenodiscard |
The action waiting for confirmation. Tracked.
- Returns
- It, or std::nullopt.
Definition at line 453 of file collection.hpp.
◆ confirm()
| void morph::forms::CollectionSession::confirm |
( |
| ) |
|
|
inline |
Runs the action waiting for confirmation, if any.
Definition at line 456 of file collection.hpp.
◆ cancelConfirm()
| void morph::forms::CollectionSession::cancelConfirm |
( |
| ) |
|
|
inline |
Drops the action waiting for confirmation: nothing is sent.
Definition at line 465 of file collection.hpp.
◆ open()
| void morph::forms::CollectionSession::open |
( |
std::string_view | rowKey | ) |
|
|
inline |
Opens the editor on a row, prefilled from the row action's bind entries with the row's exact values. A prefill replaces every field, so nothing typed for another row carries over. Programmatic, so nothing is submitted until the user edits.
- Parameters
-
| rowKey | The row's exact key text. |
Definition at line 471 of file collection.hpp.
◆ close()
| void morph::forms::CollectionSession::close |
( |
| ) |
|
|
inline |
◆ openRow()
| std::optional< std::string > const & morph::forms::CollectionSession::openRow |
( |
| ) |
const |
|
inlinenodiscard |
The row the editor is open on. Tracked.
- Returns
- Its key text, or std::nullopt.
Definition at line 488 of file collection.hpp.
◆ editor()
| FormSession * morph::forms::CollectionSession::editor |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
The row editor.
- Returns
- The editor, or null when the view has no row action or its schema is unknown or malformed.
Definition at line 492 of file collection.hpp.
◆ actionPending()
| bool morph::forms::CollectionSession::actionPending |
( |
| ) |
const |
|
inlinenodiscard |
Whether an action is in flight. Tracked.
- Returns
- true while one is.
Definition at line 496 of file collection.hpp.
◆ actionError()
| std::exception_ptr morph::forms::CollectionSession::actionError |
( |
| ) |
const |
|
inlinenodiscard |
The last action failure. Tracked.
- Returns
- The exception, or null; cleared by the next success.
Definition at line 500 of file collection.hpp.
The documentation for this class was generated from the following file: