Alternera.Resource.UI.ActionRunner (alternera_resource_ui v0.9.0)

Copy Markdown View Source

Runs a resource's declared actions for the host: asks for the action's input and confirmation in a dialog, runs it in the background with the viewer's context, and shows the outcome, its message or its error, in that dialog. An action with no input and no confirmation opens the dialog as it starts, to show it running and then its outcome. An action with input stays open for another run (a second conversion); Close ends it. The runner sends no notification of its own: a handler that wants one calls Alternera.Resource.UI.notify/3. Only an outcome whose dialog is gone (closed while it ran, or the host moved on) is said in a notification, as nothing else would show it. An outcome that opens something (open:) closes the dialog. The host mounts one per mounted surface and one on the generated page, with id, ctx (whose resource is the resource the actions belong to) and nothing else.

Two ways in:

  • a button anywhere on the page (Alternera.Resource.UI.Components.action_button/1) sends "run" to it with action and, for a record action, record (the record's id);
  • the host sends send_update(ActionRunner, id: …, run: {action_id, target}) with the target already loaded: :resource, {:record, record} or {:selection, records} (the checked rows, or every record a search matches).

After a run that changed something it tells the host its records are stale (Alternera.Resource.UI.records_changed/1).

Summary

Functions

The DOM id of the runner mounted for ctx: a button targets it.

Functions

dom_id(arg)

The DOM id of the runner mounted for ctx: a button targets it.