Skip to content

Commit

Permalink
Handle business items without a work package, and business items with…
Browse files Browse the repository at this point in the history
…out a date
  • Loading branch information
mattrayner committed Oct 25, 2018
1 parent c34014b commit 189e17e
Show file tree
Hide file tree
Showing 6 changed files with 6,999 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/controllers/procedure_steps/work_packages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ def index
@business_items = @business_items.sort_by(:date, :graph_id).reverse

list_components = @business_items.map do |business_item|
list_description_items = [].tap do |items|
items << { term: { content: 'procedure-steps.subsidiary-resources.actualised-date' }, description: [{ content: I18n.l(business_item&.date) }] }
next nil unless business_item.work_package

list_description_items = nil
if business_item.date
list_description_items = [{ term: { content: 'procedure-steps.subsidiary-resources.actualised-date' }, description: [{ content: I18n.l(business_item.date) }] }]
end

CardFactory.new(
Expand All @@ -24,12 +27,13 @@ def index
description_list_content: list_description_items
).build_card
end
list_components.compact!

heading = ComponentSerializer::Heading1ComponentSerializer.new(heading_content: I18n.t('work_packages.title'), subheading_content: @procedure_step.try(:procedureStepName), subheading_link: procedure_step_path)

serializer = PageSerializer::ListPageSerializer.new(request: request, heading_component: heading, list_components: list_components, data_alternates: @alternates)

render_page(serializer)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def meta_info
houses = @procedure_step.try(:procedureStepHasHouse)
return if houses.nil? || houses.empty?

houses = houses.map { |house| house.try(:houseName) }.compact.join(' and ')
houses = houses.map { |house| house.try(:houseName) }.compact.to_sentence

[create_description_list_item('procedure-steps.houses', [houses])]
end
Expand Down
Loading

0 comments on commit 189e17e

Please sign in to comment.