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.
|
|
|
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(case_log)
|
|
|
|
return answer_options unless case_log.owning_organisation
|
|
|
|
|
|
|
|
user_ids = case_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?(_case_log, current_user)
|
|
|
|
!current_user.support?
|
|
|
|
end
|
|
|
|
|
|
|
|
def derived?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def selected_answer_option_is_derived?(_case_log)
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|