Browse Source

Address comments

pull/968/head
Jack S 4 years ago
parent
commit
bfa40c1975
  1. 2
      app/helpers/question_attribute_helper.rb
  2. 2
      app/models/form/lettings/pages/housing_provider.rb
  3. 2
      app/models/form/lettings/pages/managing_organisation.rb
  4. 20
      app/models/form/lettings/questions/housing_provider.rb
  5. 20
      app/models/form/lettings/questions/managing_organisation.rb
  6. 4
      config/initializers/feature_toggle.rb
  7. 2
      db/seeds.rb

2
app/helpers/question_attribute_helper.rb

@ -11,7 +11,7 @@ module QuestionAttributeHelper
{ {
"data-controller": "conditional-question", "data-controller": "conditional-question",
"data-action": "click->conditional-question#displayConditional", "data-action": "click->conditional-question#displayConditional",
"data-info": { conditional_questions: conditional_for, type: type }.to_json, "data-info": { conditional_questions: conditional_for, type: }.to_json,
} }
end end

2
app/models/form/lettings/pages/housing_provider.rb

@ -13,8 +13,6 @@ class Form::Lettings::Pages::HousingProvider < ::Form::Page
] ]
end end
# For an organisation owns and manages ONLY their own housing stock AND NOT uses agents to manage the properties AND NOT manages housing stock of other organisations?
# In "set up this lettings log" no extra question should be shown
def routed_to?(log, current_user) def routed_to?(log, current_user)
return false unless current_user return false unless current_user
return true if current_user.support? return true if current_user.support?

2
app/models/form/lettings/pages/managing_organisation.rb

@ -13,8 +13,6 @@ class Form::Lettings::Pages::ManagingOrganisation < ::Form::Page
] ]
end end
# For an organisation owns and manages ONLY their own housing stock AND NOT uses agents to manage the properties AND NOT manages housing stock of other organisations?
# In "set up this lettings log" no extra question should be shown
def routed_to?(log, current_user) def routed_to?(log, current_user)
return false unless current_user return false unless current_user
return true if current_user.support? return true if current_user.support?

20
app/models/form/lettings/questions/housing_provider.rb

@ -19,10 +19,7 @@ class Form::Lettings::Questions::HousingProvider < ::Form::Question
answer_opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)" answer_opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)"
end end
housing_providers.select(:id, :name).each_with_object(answer_opts) do |organisation, hsh| answer_opts.merge(housing_providers_answer_options)
hsh[organisation.id] = organisation.name
hsh
end
end end
def displayed_answer_options(log, user = nil) def displayed_answer_options(log, user = nil)
@ -48,8 +45,7 @@ class Form::Lettings::Questions::HousingProvider < ::Form::Question
return false unless @current_user return false unless @current_user
return false if @current_user.support? return false if @current_user.support?
# Hide when less than 2 housing providers housing_providers_answer_options.count < 2
housing_providers.count < 2
end end
def enabled def enabled
@ -62,11 +58,11 @@ private
true true
end end
def housing_providers def housing_providers_answer_options
@housing_providers ||= if current_user.support? @housing_providers_answer_options ||= if current_user.support?
Organisation.all Organisation
else else
current_user.organisation.housing_providers current_user.organisation.housing_providers
end end.pluck(:id, :name).to_h
end end
end end

20
app/models/form/lettings/questions/managing_organisation.rb

@ -25,10 +25,7 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question
opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)" opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)"
end end
managing_organisations.select(:id, :name).each_with_object(opts) do |organisation, hsh| opts.merge(managing_organisations_answer_options)
hsh[organisation.id] = organisation.name
hsh
end
end end
def displayed_answer_options(log, user) def displayed_answer_options(log, user)
@ -54,8 +51,7 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question
return false unless @current_user return false unless @current_user
return false if @current_user.support? return false if @current_user.support?
# Hide when less than 2 managing_agents managing_organisations_answer_options.count < 2
managing_organisations.count < 2
end end
def enabled def enabled
@ -68,11 +64,11 @@ private
true true
end end
def managing_organisations def managing_organisations_answer_options
@managing_organisations ||= if current_user.support? @managing_organisations_answer_options ||= if current_user.support?
log.owning_organisation log.owning_organisation
else else
current_user.organisation current_user.organisation
end.managing_agents end.managing_agents.pluck(:id, :name).to_h
end end
end end

4
config/initializers/feature_toggle.rb

@ -22,8 +22,6 @@ class FeatureToggle
end end
def self.managing_for_other_user_enabled? def self.managing_for_other_user_enabled?
return true unless Rails.env.production? !Rails.env.production?
false
end end
end end

2
db/seeds.rb

@ -39,7 +39,7 @@ unless Rails.env.test?
provider_type: "LA", provider_type: "LA",
) )
managing_agent2 = Organisation.find_or_create_by!( managing_agent2 = Organisation.find_or_create_by!(
name: "Managing Agent 1", name: "Managing Agent 2",
address_line1: "2 Marsham Street", address_line1: "2 Marsham Street",
address_line2: "London", address_line2: "London",
postcode: "SW1P 4DF", postcode: "SW1P 4DF",

Loading…
Cancel
Save