Browse Source

CLDC-3187: Display org id on stock owner / managing agent pages (#2274)

* CLDC-3187: Display org id on stock owner / managing agent pages

* Fix indentation

* Refactor stock owner / managing agent list partials into one shared partial

* Fix linting

* Use managing agents instead of agents in search component display

* Update tests to reflect agents -> managing agents change
pull/2279/head^2
Rachael Booth 10 months ago committed by GitHub
parent
commit
1dcdc0806a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      app/views/organisation_relationships/_managing_agent_list.erb
  2. 36
      app/views/organisation_relationships/_related_org_list.erb
  3. 22
      app/views/organisation_relationships/_stock_owner_list.erb
  4. 11
      app/views/organisation_relationships/managing_agents.html.erb
  5. 11
      app/views/organisation_relationships/stock_owners.html.erb
  6. 6
      spec/requests/organisation_relationships_controller_spec.rb

22
app/views/organisation_relationships/_managing_agent_list.erb

@ -1,22 +0,0 @@
<section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>">
<%= 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 %>
</section>

36
app/views/organisation_relationships/_related_org_list.erb

@ -0,0 +1,36 @@
<section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>">
<%= 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 %>
</section>

22
app/views/organisation_relationships/_stock_owner_list.erb

@ -1,22 +0,0 @@
<section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>">
<%= 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 %>
</section>

11
app/views/organisation_relationships/managing_agents.html.erb

@ -22,6 +22,15 @@
<% end %> <% end %>
<% if @total_count != 0 %> <% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a managing agent", value: @searched) %> <%= 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" } %> <%= render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "managing agents" } %>
<% end %> <% end %>

11
app/views/organisation_relationships/stock_owners.html.erb

@ -19,6 +19,15 @@
<% end %> <% end %>
<% if @total_count != 0 %> <% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a stock owner", value: @searched) %> <%= 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" } %> <%= render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "stock owners" } %>
<% end %> <% end %>

6
spec/requests/organisation_relationships_controller_spec.rb

@ -113,7 +113,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end end
it "shows the pagination count" do 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
end end
@ -421,7 +421,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end end
it "shows the pagination count" do 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
end end
@ -637,7 +637,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end end
it "shows the pagination count" do 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
it "shows remove link(s)" do it "shows remove link(s)" do

Loading…
Cancel
Save