Browse Source

Add banners for stock owners and managing agents

pull/2293/head
Kat 2 years ago
parent
commit
9c071f14a8
  1. 18
      app/views/organisation_relationships/managing_agents.html.erb
  2. 18
      app/views/organisation_relationships/stock_owners.html.erb
  3. 32
      spec/requests/organisation_relationships_controller_spec.rb

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

@ -5,19 +5,35 @@
<%= render SubNavigationComponent.new( <%= render SubNavigationComponent.new(
items: secondary_items(request.path, @organisation.id), items: secondary_items(request.path, @organisation.id),
) %> ) %>
<% if !@organisation.active? %>
<%= govuk_notification_banner(title_text: "Important") do %>
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content">
This organisation is deactivated.
<p>
You cannot add any new managing agents.
<% end %>
<% end %>
<h2 class="govuk-visually-hidden">Managing Agents</h2> <h2 class="govuk-visually-hidden">Managing Agents</h2>
<p class="govuk-body">A managing agent can submit logs for this organisation.</p> <p class="govuk-body">A managing agent can submit logs for this organisation.</p>
<% if @total_count == 0 %> <% if @total_count == 0 %>
<p class="govuk-body">This organisation does not currently have any managing agents.</p> <p class="govuk-body">This organisation does not currently have any managing agents.</p>
<% end %> <% end %>
<% else %> <% else %>
<% if !@organisation.active? %>
<%= govuk_notification_banner(title_text: "Important") do %>
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content">
This organisation is deactivated.
<p>
You cannot add any new managing agents.
<% end %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "Your managing agents", sub: current_user.organisation.name } %> <%= render partial: "organisations/headings", locals: { main: "Your managing agents", sub: current_user.organisation.name } %>
<p class="govuk-body">A managing agent can submit logs for this organisation.</p> <p class="govuk-body">A managing agent can submit logs for this organisation.</p>
<% if @total_count == 0 %> <% if @total_count == 0 %>
<p class="govuk-body">This organisation does not currently have any managing agents.</p> <p class="govuk-body">This organisation does not currently have any managing agents.</p>
<% end %> <% end %>
<% end %> <% end %>
<% if current_user.support? || current_user.data_coordinator? %> <% if (current_user.support? || current_user.data_coordinator?) && @organisation.active? %>
<%= govuk_button_link_to "Add a managing agent", managing_agents_add_organisation_path, html: { method: :get } %> <%= govuk_button_link_to "Add a managing agent", managing_agents_add_organisation_path, html: { method: :get } %>
<% end %> <% end %>
<% if @total_count != 0 %> <% if @total_count != 0 %>

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

@ -2,19 +2,35 @@
<% if current_user.support? %> <% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
<% if !@organisation.active? %>
<%= govuk_notification_banner(title_text: "Important") do %>
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content">
This organisation is deactivated.
<p>
You cannot add any new stock owners.
<% end %>
<% end %>
<h2 class="govuk-visually-hidden">Stock Owners</h2> <h2 class="govuk-visually-hidden">Stock Owners</h2>
<p class="govuk-body">This organisation can submit logs for its stock owners.</p> <p class="govuk-body">This organisation can submit logs for its stock owners.</p>
<% if @total_count == 0 %> <% if @total_count == 0 %>
<p class="govuk-body">This organisation does not currently have any stock owners.</p> <p class="govuk-body">This organisation does not currently have any stock owners.</p>
<% end %> <% end %>
<% else %> <% else %>
<% if !@organisation.active? %>
<%= govuk_notification_banner(title_text: "Important") do %>
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content">
This organisation is deactivated.
<p>
You cannot add any new stock owners.
<% end %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "Your stock owners", sub: current_user.organisation.name } %> <%= render partial: "organisations/headings", locals: { main: "Your stock owners", sub: current_user.organisation.name } %>
<p class="govuk-body">Your organisation can submit logs for its stock owners.</p> <p class="govuk-body">Your organisation can submit logs for its stock owners.</p>
<% if @total_count == 0 %> <% if @total_count == 0 %>
<p class="govuk-body">You do not currently have any stock owners.</p> <p class="govuk-body">You do not currently have any stock owners.</p>
<% end %> <% end %>
<% end %> <% end %>
<% if current_user.support? || current_user.data_coordinator? %> <% if (current_user.support? || current_user.data_coordinator?) && @organisation.active? %>
<%= govuk_button_link_to "Add a stock owner", stock_owners_add_organisation_path, html: { method: :get } %> <%= govuk_button_link_to "Add a stock owner", stock_owners_add_organisation_path, html: { method: :get } %>
<% end %> <% end %>
<% if @total_count != 0 %> <% if @total_count != 0 %>

32
spec/requests/organisation_relationships_controller_spec.rb

@ -81,6 +81,22 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
expect(response.body).not_to include(inactive_organisation.name) expect(response.body).not_to include(inactive_organisation.name)
end end
end end
context "and current organisation is deactivated" do
before do
organisation.update!(active: false)
get "/organisations/#{organisation.id}/stock-owners", headers:, params: {}
end
it "does not show the add stock owner button" do
expect(page).not_to have_link("Add a stock owner")
end
it "shows a banner" do
expect(page).to have_content("This organisation is deactivated.")
expect(page).to have_content("You cannot add any new stock owners.")
end
end
end end
context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do
@ -135,6 +151,22 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
it "shows the pagination count" do it "shows the pagination count" do
expect(page).to have_content("1 total managing agents") expect(page).to have_content("1 total managing agents")
end end
context "and current organisation is deactivated" do
before do
organisation.update!(active: false)
get "/organisations/#{organisation.id}/managing-agents", headers:, params: {}
end
it "does not show the add managing agent button" do
expect(page).not_to have_link("Add a managing agent")
end
it "shows a banner" do
expect(page).to have_content("This organisation is deactivated.")
expect(page).to have_content("You cannot add any new managing agents.")
end
end
end end
context "when adding a managing agent" do context "when adding a managing agent" do

Loading…
Cancel
Save