app/helpers/application_helper.rb
# TODO: refactor enrichment_summary method to not use an instance variable
# rubocop:disable Rails/HelperInstanceVariable
refactor enrichment_summary method to not use an instance variable
rubocop:disable Rails/HelperInstanceVariable
refactor enrichment_summary method to not use an instance variable rubocop : disable Rails / HelperInstanceVariable
def enrichment_summary(summary_list, model, key, value, fields, truncate_value: true, action_path: nil, action_visually_hidden_text: nil)
    action = render_action(action_path, action_visually_hidden_text)
    if fields.select { |field| @errors&.key? field.to_sym }.any?
      errors = fields.map { |field|
        @errors[field.to_sym]&.map { |error| enrichment_error_link(model, field, error) }
      }.flatten
      value = raw(*errors)
      action = nil
    elsif truncate_value
      classes = "app-summary-list__value--truncate"
    end
    if value.blank?
      value = raw("<span class=\"app-!-colour-muted\">Empty</span>")
    end
    summary_list.row(html_attributes: { data: { qa: "enrichment__#{fields.first}" } }) do |row|
      row.key { key.html_safe }
      row.value(classes: classes) { value }
      if action
        row.action(action)
      else
        row.action
      end
    end
  end
def enrichment_summary ( summary_list , model , key , value , fields , truncate_value : true , action_path : nil , action_visually_hidden_text : nil ) action = render_action ( action_path , action_visually_hidden_text ) if fields . select { | field | @errors &. key? field . to_sym } . any? errors = fields . map { | field | @errors [ field . to_sym ] &. map { | error | enrichment_error_link ( model , field , error ) } } . flatten value = raw ( * errors ) action = nil elsif truncate_value classes = "app-summary-list__value--truncate" end if value . blank? value = raw ( "<span class=\"app-!-colour-muted\">Empty</span>" ) end summary_list . row ( html_attributes : { data : { qa : "enrichment__#{fields.first}" } } ) do | row | row . key { key . html_safe } row . value ( classes : classes ) { value } if action row . action ( action ) else row . action end end end
TODO: refactor enrichment_summary method to not use an instance variable
rubocop:disable Rails/HelperInstanceVariable
TODO : refactor enrichment_summary method to not use an instance variable rubocop : disable Rails / HelperInstanceVariable
summary_list
<not_specific>
model
<not_specific>
key
<not_specific>
value
<not_specific>
fields
<not_specific>
truncate_value
<not_specific>
action_path
<not_specific>
action_visually_hidden_text
<not_specific>