Files
baclight/app/forms/employer_setup_form.rb
T

80 lines
1.9 KiB
Ruby
Raw Normal View History

2025-11-24 08:22:44 -05:00
class EmployerSetupForm
include ActiveModel::Model
include ActiveModel::Attributes
FIRST_STEP = "general_information"
attribute :current_step, :string, default: FIRST_STEP
attribute :pl_plan_key, :string
2025-11-24 08:22:44 -05:00
def initialize(params = {})
# if params.present?
# params = permitted_params(params)
# end
super(params)
2025-11-24 08:22:44 -05:00
unless self.steps.first == FIRST_STEP
raise StepMisalignmentError, "FIRST_STEP does not match first entry in steps"
end
# @general_information_data = EmployerSetupGeneralInformationForm.new(attributes[:general_information_data])
# @plans_data = EmployerSetupPlansForm.new(attributes[:plans_data])
# @network_exceptions_data = EmployerSetupNetworkExceptionsForm.new(attributes[:network_exceptions_data])
2025-11-24 08:22:44 -05:00
end
# def self.form_session_init
# {
# general_information_data: {},
# plans_data: {},
# network_exceptions_data: {}
# }
# end
# def steps
# %w[general_information plans network_exceptions summary]
# end
2025-11-24 08:22:44 -05:00
def steps
%w[general_information plans network_exceptions summary]
end
def current_step_view
"employer_setup/#{self.current_step}"
end
def next_step
index = steps.index(current_step)
if index && index < steps.length - 1
steps[index + 1]
2025-11-24 08:22:44 -05:00
end
end
def previous_step
index = steps.index(current_step)
steps[index - 1] if index && index > 0
end
def permitted_params(params)
params.require(:employer_setup_data).permit(
:pl_plan_key,
:current_step
)
2025-11-24 08:22:44 -05:00
end
def self.permitted_params
[
:pl_plan_key,
:current_step
]
end
# def save
# if valid?
# EmployerSetupGeneralInformationForm.new(attributes[:general_information_data]).save
# EmployerSetupPlansForm.new(attributes[:plans_data]).save
# EmployerSetupNetworkExceptionsForm.new(attributes[:network_exceptions_data]).save
# true
# else
# false
# end
# end
2025-11-24 08:22:44 -05:00
end