Alternera.Plugin.Editor.Conditions (alternera_plugin_editor v0.9.0)

Copy Markdown View Source

A list of conditions in a step editor: the picker that adds one (picker/1), the rows that edit them (rows/1), the types a side offers (types/1) and a new condition of a type (default_condition/1).

Conditions are the proxy's: their types, operators and fields are what its matcher evaluates, and the rows draw masked values, the steps before this one and the proxy user select. So the editor package draws them through the host's condition editor, named by config :alternera_plugin_editor, :conditions, Module (the proxy names AlterneraWeb.Components.ConditionEditor), whose picker/1, rows/1, node_types/1 and default_condition/1 these call. Without a host, as in a plugin's own tests, the picker and the rows draw a note that conditions are edited in the pipeline editor, types/1 answers [] and default_condition/1 a bare %{"type" => type, "value" => ""}.

The rows hold the conditions as a map of key to condition, and every event names a condition by its key alone; the step editor keeps them in its settings as lists and makes the keys itself ("<list>-<index>", say). The events, all sent to target:

  • add_node_condition, from the picker, with node_condition_type[<owner>] the type picked;
  • update_condition (key, field, value);
  • update_condition_operator (a param named operator_<key>);
  • update_condition_field (condition[<key>][<field>], _target naming it: the fields of a variable, step, response status, response header or error condition);
  • remove_condition (key).

Summary

Functions

A new condition of type, as the picker adds it.

The select that adds a condition: owner names the list it adds to, which comes back in the event's node_condition_type[<owner>].

The condition rows, each with its type, its fields and a remove button. id_prefix starts each row's DOM id, followed by its key; text_event is "keyup" (debounced, and on blur) or "blur"; steps_before are the earlier steps a step condition may read (the step editor's own steps_before); numbered_labels names each row's controls for a screen reader by position and type.

The condition types a list read on side offers, {label, type}: "request" for one decided on the request, "response" for one decided on the response head, which adds the response's status and headers.

Functions

default_condition(type)

@spec default_condition(String.t()) :: map()

A new condition of type, as the picker adds it.

picker(assigns)

The select that adds a condition: owner names the list it adds to, which comes back in the event's node_condition_type[<owner>].

Attributes

  • id (:string) (required)
  • owner (:string) (required)
  • types (:list) (required) - {label, type}, as types/1 gives them.
  • target (:any) (required)
  • aria_label (:string) - Defaults to "Add condition".

rows(assigns)

The condition rows, each with its type, its fields and a remove button. id_prefix starts each row's DOM id, followed by its key; text_event is "keyup" (debounced, and on blur) or "blur"; steps_before are the earlier steps a step condition may read (the step editor's own steps_before); numbered_labels names each row's controls for a screen reader by position and type.

Attributes

  • conditions (:map) (required)
  • target (:any) (required)
  • id_prefix (:string) (required)
  • text_event (:string) - Defaults to "keyup". Must be one of "blur", or "keyup".
  • steps_before (:list) - Defaults to [].
  • numbered_labels (:boolean) - Defaults to false.
  • class (:string) - Defaults to "space-y-2".

types(side)

@spec types(String.t()) :: [{String.t(), String.t()}]

The condition types a list read on side offers, {label, type}: "request" for one decided on the request, "response" for one decided on the response head, which adds the response's status and headers.