2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-25 13:14:56 -04:00
|
|
|
class Wizard
|
|
|
|
class Step
|
2016-09-09 16:51:07 -04:00
|
|
|
attr_reader :id, :updater
|
2023-09-25 22:34:38 -04:00
|
|
|
attr_accessor :index, :fields, :next, :previous, :disabled, :description_vars, :emoji
|
2016-08-25 13:14:56 -04:00
|
|
|
|
|
|
|
def initialize(id)
|
|
|
|
@id = id
|
|
|
|
@fields = []
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_field(attrs)
|
|
|
|
field = Field.new(attrs)
|
|
|
|
field.step = self
|
|
|
|
@fields << field
|
2024-07-29 02:07:06 -04:00
|
|
|
yield field if block_given?
|
2016-08-25 13:14:56 -04:00
|
|
|
field
|
|
|
|
end
|
2016-09-09 16:51:07 -04:00
|
|
|
|
2016-09-14 16:36:08 -04:00
|
|
|
def has_fields?
|
|
|
|
@fields.present?
|
|
|
|
end
|
|
|
|
|
2016-09-09 16:51:07 -04:00
|
|
|
def on_update(&block)
|
|
|
|
@updater = block
|
|
|
|
end
|
2016-08-25 13:14:56 -04:00
|
|
|
end
|
|
|
|
end
|