|
|
|
@ -11,6 +11,8 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question |
|
|
|
answer_opts = { "" => "Select an option" } |
|
|
|
answer_opts = { "" => "Select an option" } |
|
|
|
|
|
|
|
|
|
|
|
return answer_opts unless ActiveRecord::Base.connected? |
|
|
|
return answer_opts unless ActiveRecord::Base.connected? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if FeatureToggle.merge_organisations_enabled? |
|
|
|
return answer_opts unless user |
|
|
|
return answer_opts unless user |
|
|
|
return answer_opts unless log |
|
|
|
return answer_opts unless log |
|
|
|
|
|
|
|
|
|
|
|
@ -29,6 +31,12 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question |
|
|
|
end.pluck(:id, :name).to_h |
|
|
|
end.pluck(:id, :name).to_h |
|
|
|
|
|
|
|
|
|
|
|
answer_opts.merge(user_answer_options) |
|
|
|
answer_opts.merge(user_answer_options) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Organisation.select(:id, :name).each_with_object(answer_opts) do |organisation, hsh| |
|
|
|
|
|
|
|
hsh[organisation.id] = organisation.name |
|
|
|
|
|
|
|
hsh |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def displayed_answer_options(log, user = nil) |
|
|
|
def displayed_answer_options(log, user = nil) |
|
|
|
@ -46,6 +54,7 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def hidden_in_check_answers?(_log, user = nil) |
|
|
|
def hidden_in_check_answers?(_log, user = nil) |
|
|
|
|
|
|
|
if FeatureToggle.merge_organisations_enabled? |
|
|
|
return false if user.support? |
|
|
|
return false if user.support? |
|
|
|
|
|
|
|
|
|
|
|
stock_owners = user.organisation.stock_owners + user.organisation.absorbed_organisations.where(holds_own_stock: true) |
|
|
|
stock_owners = user.organisation.stock_owners + user.organisation.absorbed_organisations.where(holds_own_stock: true) |
|
|
|
@ -55,6 +64,9 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question |
|
|
|
else |
|
|
|
else |
|
|
|
stock_owners.count <= 1 |
|
|
|
stock_owners.count <= 1 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
!current_user.support? |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def enabled |
|
|
|
def enabled |
|
|
|
@ -64,6 +76,6 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question |
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def selected_answer_option_is_derived?(_log) |
|
|
|
def selected_answer_option_is_derived?(_log) |
|
|
|
true |
|
|
|
FeatureToggle.merge_organisations_enabled? ? true : false |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|