Browse Source

feat: allow has_other_client_group nil, but enforce yes if a secondary client group exists

CLDC-1741-scheme-attributes-bug-fix
natdeanlewissoftwire 2 years ago
parent
commit
e80d148284
  1. 2
      app/helpers/schemes_helper.rb
  2. 3
      app/models/derived_variables/scheme_variables.rb
  3. 2
      app/models/scheme.rb

2
app/helpers/schemes_helper.rb

@ -11,7 +11,7 @@ module SchemesHelper
{ name: "Support services provided by", value: scheme.arrangement_type }, { name: "Support services provided by", value: scheme.arrangement_type },
{ name: "Primary client group", value: scheme.primary_client_group }, { name: "Primary client group", value: scheme.primary_client_group },
{ name: "Has another client group", value: scheme.has_other_client_group }, { name: "Has another client group", value: scheme.has_other_client_group },
scheme.has_other_client_group == "Yes" ? { name: "Secondary client group", value: scheme.secondary_client_group } : nil, scheme.has_other_client_group == "No" ? nil : { name: "Secondary client group", value: scheme.secondary_client_group },
{ name: "Level of support given", value: scheme.support_type }, { name: "Level of support given", value: scheme.support_type },
{ name: "Intended length of stay", value: scheme.intended_stay }, { name: "Intended length of stay", value: scheme.intended_stay },
{ name: "Availability", value: scheme_availability(scheme) }, { name: "Availability", value: scheme_availability(scheme) },

3
app/models/derived_variables/scheme_variables.rb

@ -3,5 +3,8 @@ module DerivedVariables::SchemeVariables
if has_other_client_group == "No" if has_other_client_group == "No"
self.secondary_client_group = nil self.secondary_client_group = nil
end end
if secondary_client_group.present?
self.has_other_client_group = "Yes"
end
end end
end end

2
app/models/scheme.rb

@ -192,7 +192,7 @@ class Scheme < ApplicationRecord
end end
def validate_confirmed def validate_confirmed
required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units deactivation_date deactivation_date_type] required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type]
if confirmed == true if confirmed == true
required_attributes.any? do |attribute| required_attributes.any? do |attribute|

Loading…
Cancel
Save