mix ash_workflow.gen.approval (AshWorkflow v0.12.0)

Copy Markdown View Source

Adds an approval workflow to a resource

Generates an approval resource that runs the approval workflow for the subject resource, and a decision resource with one row per approver. The subject gains has_many :approvals, has_one :latest_approval and an approved? calculation. When the subject does not exist, it is created with mix ash.gen.resource first.

Nobody may open a request or approve until the application defines who can, in the generated Checks.CanRequest and Checks.CanApprove modules.

Example

mix ash_workflow.gen.approval MyApp.Expenses.Expense --approver MyApp.Accounts.User --overdue-after 2d

Options

  • --approver - required. The actor resource. Decisions and the requester belong to it.
  • --module - the approval resource's module name. Defaults to the subject's name with Approval appended.
  • --domain - the domain for a subject the task creates. Required only when the subject does not exist.
  • --required-approvals - the number of approvals a request needs. Defaults to 1.
  • --overdue-after - moves a request nobody has decided to :overdue after this long, given as 30m, 12h, 2d or 2w. A duration under a minute needs AshWorkflow.Scheduler.Precise. Without it, no :overdue step is generated.
  • --transition-log - also generates a transition log for the approval with mix ash_workflow.gen.transition_log. Defaults to true.