SelectoComponents.Views (selecto_components v0.4.5)

View tuple helpers and shared parameter-shaping helpers.

view-registration

View Registration

Register views in your LiveView as {id, module, name, options} tuples:

views = [
  SelectoComponents.Views.spec(
    :aggregate,
    SelectoComponents.Views.Aggregate,
    "Aggregate View",
    %{drill_down: :detail}
  ),
  SelectoComponents.Views.spec(:detail, SelectoComponents.Views.Detail, "Detail View", %{})
]

state = get_initial_state(views, selecto)
socket = assign(socket, views: views)

formal-view-interface

Formal View Interface

The preferred interface is SelectoComponents.Views.System:

  • initial_state/2
  • param_to_state/2
  • view/5
  • form_component/0
  • result_component/0

Built-in views use this behavior (Aggregate, Detail, Graph, Map).

Link to this section Summary

Functions

Canonical constructor for a view tuple used by SelectoComponents.

Append extension-provided views for a Selecto/domain source.

Link to this section Types

@type view_id() :: atom()
Link to this type

view_module()

@type view_module() :: module()
@type view_name() :: String.t()
Link to this type

view_options()

@type view_options() :: map()
Link to this type

view_tuple()

@type view_tuple() :: {view_id(), view_module(), view_name(), view_options()}

Link to this section Functions

Link to this function

spec(id, module, name, options \\ %{})

@spec spec(view_id(), view_module(), view_name(), view_options()) :: view_tuple()

Canonical constructor for a view tuple used by SelectoComponents.

views = [
  SelectoComponents.Views.spec(
    :workflow,
    SelectoComponentsWorkflow.Views.Workflow,
    "Workflow View",
    %{drill_down: :detail}
  )
]
Link to this function

view_param_process(params, item_name, section)

Link to this function

with_extensions(base_views, selecto_or_domain)

@spec with_extensions([view_tuple()], map()) :: [view_tuple()]

Append extension-provided views for a Selecto/domain source.

Existing views take precedence when IDs collide.