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

Copy Markdown View Source

Header names and values as a <.suggest_input> offers them: the names recorded in the source exchange first, then Alternera.Plugin.HeaderCatalogue's, and for a value field the catalogue's typical values of the header its row names.

A recorded name keeps its recorded spelling and says "In the source exchange" under it; a catalogue name that is already recorded, ignoring case, is left out, so content-type and Content-Type are not offered twice. A catalogue entry shows its description under it.

A value field's list follows the name its row holds on the server, so it changes on the re-render after the name's phx-change; a header with no typical values (or a name not in the catalogue) gives nil, and the input renders plain.

Summary

Types

An entry as the SuggestInput hook reads it.

Functions

The catalogue's names of side as suggestions, with their descriptions.

The lists in order, each name kept the first time it appears, ignoring case: so whatever comes first decides the spelling and the description.

The header names side offers: recorded (names, or {name, value} pairs as PipelinesLive.NameHints holds them) first, then the catalogue's not among them.

names/2 as JSON, for a caller that shares one list between many inputs.

The recorded names as suggestions, saying where they come from.

The typical values of the header name in side, or nil when the catalogue has none for it.

Types

suggestion()

@type suggestion() :: %{value: String.t(), description: String.t() | nil}

An entry as the SuggestInput hook reads it.

Functions

catalogue(side)

The catalogue's names of side as suggestions, with their descriptions.

merge(lists)

@spec merge([[suggestion()]]) :: [suggestion()]

The lists in order, each name kept the first time it appears, ignoring case: so whatever comes first decides the spelling and the description.

names(side, recorded \\ [])

@spec names(Alternera.Plugin.HeaderCatalogue.side(), [
  String.t() | {String.t(), term()}
]) :: [
  suggestion()
]

The header names side offers: recorded (names, or {name, value} pairs as PipelinesLive.NameHints holds them) first, then the catalogue's not among them.

names_json(side, recorded \\ [])

@spec names_json(Alternera.Plugin.HeaderCatalogue.side(), [
  String.t() | {String.t(), term()}
]) ::
  String.t()

names/2 as JSON, for a caller that shares one list between many inputs.

recorded(names)

@spec recorded([String.t() | {String.t(), term()}]) :: [suggestion()]

The recorded names as suggestions, saying where they come from.

values(side, name)

@spec values(Alternera.Plugin.HeaderCatalogue.side(), String.t() | nil) ::
  [suggestion()] | nil

The typical values of the header name in side, or nil when the catalogue has none for it.