diff --git a/app/views/organisation_relationships/_managing_agent_list.erb b/app/views/organisation_relationships/_managing_agent_list.erb
deleted file mode 100644
index 81a1f6070..000000000
--- a/app/views/organisation_relationships/_managing_agent_list.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-
- <%= govuk_table do |table| %>
- <%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "agents", filters_count: 0)) %>
- <% end %>
- <% @managing_agents.each do |managing_agent| %>
- <%= table.with_body do |body| %>
- <%= body.with_row do |row| %>
- <% row.with_cell(text: managing_agent.name) %>
- <% if current_user.data_coordinator? || current_user.support? %>
- <% row.with_cell(html_attributes: {
- scope: "row",
- class: "govuk-!-text-align-right",
- }) do %>
- <%= govuk_link_to("Remove", managing_agents_remove_organisation_path(target_organisation_id: managing_agent.id)) %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
-
diff --git a/app/views/organisation_relationships/_related_org_list.erb b/app/views/organisation_relationships/_related_org_list.erb
new file mode 100644
index 000000000..e4c32f23f
--- /dev/null
+++ b/app/views/organisation_relationships/_related_org_list.erb
@@ -0,0 +1,36 @@
+
+ <%= govuk_table do |table| %>
+ <%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
+ <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: search_item, filters_count: 0)) %>
+ <% end %>
+ <%= table.with_head do |head| %>
+ <%= head.with_row do |row| %>
+ <% row.with_cell(header: true, text: "Organisation name", html_attributes: { scope: "col", class: "govuk-!-width-one-half" }) %>
+ <% row.with_cell(header: true, text: "Organisation ID", html_attributes: { scope: "col", class: "govuk-!-width-one-half" }) %>
+ <% if current_user.data_coordinator? || current_user.support? %>
+ <% row.with_cell %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <%= table.with_body do |body| %>
+ <% related_orgs.each do |org| %>
+ <%= body.with_row do |row| %>
+ <% if current_user.support? %>
+ <% row.with_cell(text: simple_format(govuk_link_to(org.name, organisation_path(org)), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
+ <% else %>
+ <% row.with_cell(text: org.name) %>
+ <% end %>
+ <% row.with_cell(text: "ORG#{org.id}") %>
+ <% if current_user.data_coordinator? || current_user.support? %>
+ <% row.with_cell(html_attributes: {
+ scope: "row",
+ class: "govuk-!-text-align-right",
+ }) do %>
+ <%= govuk_link_to("Remove", remove_path.call(org.id)) %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% end %>
+
diff --git a/app/views/organisation_relationships/_stock_owner_list.erb b/app/views/organisation_relationships/_stock_owner_list.erb
deleted file mode 100644
index 2fb0de80b..000000000
--- a/app/views/organisation_relationships/_stock_owner_list.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-
- <%= govuk_table do |table| %>
- <%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "stock owners", filters_count: 0)) %>
- <% end %>
- <% @stock_owners.each do |stock_owner| %>
- <%= table.with_body do |body| %>
- <%= body.with_row do |row| %>
- <% row.with_cell(text: stock_owner.name) %>
- <% if current_user.data_coordinator? || current_user.support? %>
- <% row.with_cell(html_attributes: {
- scope: "row",
- class: "govuk-!-text-align-right",
- }) do %>
- <%= govuk_link_to("Remove", stock_owners_remove_organisation_path(target_organisation_id: stock_owner.id)) %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
-
diff --git a/app/views/organisation_relationships/managing_agents.html.erb b/app/views/organisation_relationships/managing_agents.html.erb
index 09d326b8b..a01a354d2 100644
--- a/app/views/organisation_relationships/managing_agents.html.erb
+++ b/app/views/organisation_relationships/managing_agents.html.erb
@@ -22,6 +22,15 @@
<% end %>
<% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a managing agent", value: @searched) %>
- <%= render partial: "organisation_relationships/managing_agent_list", locals: { index: @managing_agents, title: "Managing agents", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %>
+ <%= render partial: "organisation_relationships/related_org_list", locals: {
+ related_orgs: @managing_agents,
+ title: "Managing agents",
+ pagy: @pagy,
+ searched: @searched,
+ item_label:,
+ search_item: "managing agents",
+ total_count: @total_count,
+ remove_path: ->(org_id) { managing_agents_remove_organisation_path(target_organisation_id: org_id) },
+ } %>
<%= render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "managing agents" } %>
<% end %>
diff --git a/app/views/organisation_relationships/stock_owners.html.erb b/app/views/organisation_relationships/stock_owners.html.erb
index 8149a261c..4be22f7b9 100644
--- a/app/views/organisation_relationships/stock_owners.html.erb
+++ b/app/views/organisation_relationships/stock_owners.html.erb
@@ -19,6 +19,15 @@
<% end %>
<% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a stock owner", value: @searched) %>
- <%= render partial: "organisation_relationships/stock_owner_list", locals: { index: @stock_owners, title: "Stock owners", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %>
+ <%= render partial: "organisation_relationships/related_org_list", locals: {
+ related_orgs: @stock_owners,
+ title: "Stock owners",
+ pagy: @pagy,
+ searched: @searched,
+ item_label:,
+ search_item: "stock owners",
+ total_count: @total_count,
+ remove_path: ->(org_id) { stock_owners_remove_organisation_path(target_organisation_id: org_id) },
+ } %>
<%= render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "stock owners" } %>
<% end %>
diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb
index a93e77d76..4c22a2aa2 100644
--- a/spec/requests/organisation_relationships_controller_spec.rb
+++ b/spec/requests/organisation_relationships_controller_spec.rb
@@ -113,7 +113,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total agents")
+ expect(page).to have_content("1 total managing agents")
end
end
@@ -421,7 +421,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total agents")
+ expect(page).to have_content("1 total managing agents")
end
end
@@ -637,7 +637,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total agents")
+ expect(page).to have_content("1 total managing agents")
end
it "shows remove link(s)" do