Skip to content

Commit

Permalink
Flatten edition links for Worldwide Organisations
Browse files Browse the repository at this point in the history
As edition links do not support multi-level or recursive link expansion,
we need to explicitly include all the sub-links that we require to
render this page.
  • Loading branch information
brucebolt committed Jan 22, 2024
1 parent c4e47b4 commit 7913e3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ def content

def edition_links
{
contacts:,
corporate_information_pages:,
main_office:,
home_page_offices:,
primary_role_person:,
roles:,
role_appointments:,
secondary_role_person:,
office_staff:,
sponsoring_organisations:,
world_locations:,
roles:,
}
end

Expand Down Expand Up @@ -91,6 +93,10 @@ def about_us
end
end

def contacts
[item.main_office&.contact&.content_id] + item.home_page_offices&.map(&:contact)&.map(&:content_id)
end

def main_office
return [] unless item.main_office

Expand Down Expand Up @@ -119,6 +125,10 @@ def office_staff
item.office_staff_roles.map(&:current_person).map(&:content_id)
end

def role_appointments
item.roles.distinct.map(&:current_role_appointment).map(&:content_id)
end

def roles
item.roles.distinct.pluck(:content_id)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def present(...)
],
},
links: {
contacts: [
worldwide_org.reload.offices.first.contact.content_id,
],
corporate_information_pages: [
worldwide_org.corporate_information_pages[0].content_id,
worldwide_org.corporate_information_pages[1].content_id,
Expand Down Expand Up @@ -99,6 +102,9 @@ def present(...)
roles: [
ambassador.roles.first.content_id, deputy_head_of_mission.roles.first.content_id
],
role_appointments: [
ambassador.roles.first.current_role_appointment.content_id, deputy_head_of_mission.roles.first.current_role_appointment.content_id
],
},
analytics_identifier: "WO123",
update_type: "major",
Expand Down

0 comments on commit 7913e3a

Please sign in to comment.