MishkaCmsMigrationWeb. Live. Admin. Dashboard. ImportSteps
(Mishka CMS Migration v0.0.1)
Copy Markdown
View Source
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:
- Where from: the source and its connection (group
:connection); - What to bring: a switch for each kind (group
:bring); - Languages: one language for everything, or the source's own (field
:language); - 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.
Summary
Functions
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.
Whether the form may move past current_step: no field the step draws holds an error in the
validated form (step_errors/2).
Move to the previous step in the wizard.
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.
Jump to a specific step (for tabs/free navigation mode).
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.
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).
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.
Functions
@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.
@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.
@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.
@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.
@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.
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, 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)
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.