# `MishkaCmsMigrationWeb.Live.Admin.Dashboard.ImportSteps`
[🔗](https://github.com/mishka-group/mishka_cms_migration/blob/v0.0.1/lib/mishka_cms_migration_web/live/admin/dashboard/import_steps.ex#L5)

The steps of the New import window (`MishkaCmsMigration.MigrationRun`'s form), for an admin who
wants few choices. The form is Gervaz's `:wizard` layout: every step is in the form and only the
current one shows, so an answer stays while the admin moves between them; Next checks the step
before it moves on, Enter in a field is Next, and only the review starts the run:

  1. Where from: the source and its connection (group `:connection`);
  2. What to bring: a switch for each kind (group `:bring`);
  3. Languages: one language for everything, or the source's own (field `:language`);
  4. Review: what the run will do in plain words (`review/1`), and the Advanced options (group
     `:options`, collapsed), then Start the dry run.

It is the form's step handler (`MishkaGervaz.Form.Web.Events.StepHandler`). Leaving Where from
checks more than the fields' own errors: a connection key the source requires that is blank is
refused as "Enter the application password." (the key's label), and a filled connection is tried
(`MishkaCmsMigration.Source.connect/4`): one the source refuses stays on the step with the reason
in the words the save uses (`MishkaCmsMigration.Resources.Changes.CheckConnection.message/2`). A
source that reads a file asks for the file instead, and reads it only when the run starts. A save
refused on an earlier step, such as a connection that stopped answering, goes back to it with
the error and an error flash naming the step (Gervaz's `goto_errors/2`).

`start_over/1` draws Start over, which empties the window and returns it to the first step: the
answers are otherwise kept while the window is closed and opened again, until a run starts.

# `advance`

```elixir
@spec advance(MishkaGervaz.Form.Web.State.t(), Phoenix.LiveView.Socket.t()) ::
  Phoenix.LiveView.Socket.t()
@spec advance(map(), Phoenix.LiveView.Socket.t()) :: Phoenix.LiveView.Socket.t()
```

Moves on from Where from only once the connection is filled and the source answers it (see the
module doc); every other step moves on as Gervaz's step handler moves it. A refused Where from
shows every error it has at once: a blank site beside a blank connection key. The connection is
tried only once nothing else on the step is refused.

# `can_advance?`

```elixir
@spec can_advance?(MishkaGervaz.Form.Web.State.t(), atom()) :: boolean()
```

Whether the form may move past `current_step`: no field the step draws holds an error in the
validated form (`step_errors/2`).

Override for custom per-step validation.

# `go_back`

```elixir
@spec go_back(MishkaGervaz.Form.Web.State.t(), Phoenix.LiveView.Socket.t()) ::
  Phoenix.LiveView.Socket.t()
```

Move to the previous step in the wizard.

Uses wizard_history to determine the previous step.

# `goto_errors`

```elixir
@spec goto_errors(MishkaGervaz.Form.Web.State.t(), Phoenix.LiveView.Socket.t()) ::
  Phoenix.LiveView.Socket.t()
```

Moves a form whose save failed to the first step holding a field with an error
(`state.errors`), and marks every step holding one `:error`.

When that step is not the one the save was sent from, it also sends the parent LiveView
`{:put_flash, :error, message}`, the message being the field's first error followed by the
step to check, such as "Nothing answered at this address. Check it on step 1, Where from.".
A form whose errors are on no field (`state.form_errors`) stays where it is: those show
above the submit row.

# `goto_step`

```elixir
@spec goto_step(MishkaGervaz.Form.Web.State.t(), atom(), Phoenix.LiveView.Socket.t()) ::
  Phoenix.LiveView.Socket.t()
```

Jump to a specific step (for tabs/free navigation mode).

Only allowed when layout_navigation is :free, or the target step
has been visited before.

# `review`

The review step: its heading, "4 of 4: Review", and `summary/1` in lines. It is part of the form,
so it follows each answer as the admin changes it.

## Attributes

* `state` (`:map`) (required)

# `start_over`

Start over, a quiet button that empties the window with the form component `id` and returns it
to its first step (`MishkaGervaz.Form.Web.Live.reset/2`).

## Attributes

* `id` (`:string`) (required)

# `summary`

```elixir
@spec summary(map()) :: [{atom(), String.t()}]
```

The review's lines as `{role, words}` pairs for the form `state`: `:from`, `:bring`, `:left_out`
(omitted when nothing is switched off), `:choices` (omitted when every Advanced choice is at its
default), `:settings` (omitted when none is left out), `:language` and `:dry_run`. An answer the
form does not hold yet is the run's default.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
