Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.1 KiB

class Form::Setup::Questions::CreatedById < ::Form::Question
def initialize(id, hsh, page)
super
@id = "created_by_id"
@check_answer_label = "User"
@header = "Which user are you creating this log for?"
@hint_text = ""
@type = "select"
@page = page
end
def answer_options
answer_opts = { "" => "Select an option" }
return answer_opts unless ActiveRecord::Base.connected?
User.select(:id, :name).each_with_object(answer_opts) do |user, hsh|
hsh[user.id] = user.name
hsh
end
end
def displayed_answer_options(lettings_log)
return answer_options unless lettings_log.owning_organisation
user_ids = lettings_log.owning_organisation.users.pluck(:id) + [""]
answer_options.select { |k, _v| user_ids.include?(k) }
end
def label_from_value(value)
return unless value
answer_options[value]
end
def hidden_in_check_answers?(_lettings_log, current_user)
!current_user.support?
end
def derived?
true
end
private
def selected_answer_option_is_derived?(_lettings_log)
false
end
end