2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-25 13:14:56 -04:00
|
|
|
class Wizard
|
2016-08-31 13:35:49 -04:00
|
|
|
|
2016-09-07 18:04:01 -04:00
|
|
|
class Choice
|
2016-09-21 11:22:46 -04:00
|
|
|
attr_reader :id, :label, :icon, :data, :extra_label
|
2016-09-07 18:04:01 -04:00
|
|
|
attr_accessor :field
|
|
|
|
|
|
|
|
def initialize(id, opts)
|
|
|
|
@id = id
|
|
|
|
@data = opts[:data]
|
|
|
|
@label = opts[:label]
|
2016-09-21 11:22:46 -04:00
|
|
|
@extra_label = opts[:extra_label]
|
2016-09-09 15:57:44 -04:00
|
|
|
@icon = opts[:icon]
|
2016-09-07 18:04:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Field
|
2022-08-14 20:22:07 -04:00
|
|
|
attr_reader :id, :type, :required, :value, :icon, :choices, :disabled, :show_in_sidebar
|
2016-08-25 13:14:56 -04:00
|
|
|
attr_accessor :step
|
|
|
|
|
|
|
|
def initialize(attrs)
|
|
|
|
attrs = attrs || {}
|
|
|
|
|
|
|
|
@id = attrs[:id]
|
|
|
|
@type = attrs[:type]
|
|
|
|
@required = !!attrs[:required]
|
|
|
|
@value = attrs[:value]
|
2022-07-26 21:23:01 -04:00
|
|
|
@icon = attrs[:icon]
|
2022-08-14 20:22:07 -04:00
|
|
|
@disabled = attrs[:disabled]
|
2016-09-07 18:04:01 -04:00
|
|
|
@choices = []
|
2021-08-25 17:10:12 -04:00
|
|
|
@show_in_sidebar = attrs[:show_in_sidebar]
|
2016-08-31 13:35:49 -04:00
|
|
|
end
|
|
|
|
|
2016-09-07 18:04:01 -04:00
|
|
|
def add_choice(id, opts = nil)
|
|
|
|
choice = Choice.new(id, opts || {})
|
|
|
|
choice.field = self
|
|
|
|
|
|
|
|
@choices << choice
|
|
|
|
choice
|
2016-08-25 13:14:56 -04:00
|
|
|
end
|
2016-08-31 13:35:49 -04:00
|
|
|
|
2016-08-25 13:14:56 -04:00
|
|
|
end
|
|
|
|
end
|