Browse Source

allow support users edit or and add sub navigation to about this org

pull/557/head
Kat 3 years ago
parent
commit
25f3d7a028
  1. 11
      app/helpers/organisation_helper.rb
  2. 2
      app/views/layouts/organisations.html.erb
  3. 2
      app/views/organisations/logs.erb
  4. 9
      app/views/organisations/show.html.erb
  5. 19
      spec/requests/organisations_controller_spec.rb

11
app/helpers/organisation_helper.rb

@ -0,0 +1,11 @@
module OrganisationHelper
def organisation_header(path, user, current_organisation)
if path == "/organisations"
"Organisations"
elsif user.organisation_id == current_organisation.id
"Your organisation"
else
current_organisation.name
end
end
end

2
app/views/layouts/organisations.html.erb

@ -1,6 +1,6 @@
<% content_for :content do %>
<h1 class="govuk-heading-l">
<%= request.path == "/organisations" ? "Organisations" : "Your organisation" %>
<%= organisation_header(request.path, current_user, @organisation)%>
</h1>
<% items = tab_items(current_user) %>

2
app/views/organisations/logs.erb

@ -5,7 +5,7 @@
<%= content_for(:title) %>
</h1>
<div class="govuk-!-margin-bottom-4">
<%= render NavigationComponent.new(
<%= render NavigationComponent.new(
items: secondary_items(request.path, @organisation.id),
level: "sub"
) %>

9
app/views/organisations/show.html.erb

@ -5,10 +5,17 @@
<% end %>
<div class="govuk-grid-row">
<div class="govuk-!-margin-bottom-4">
<%= render NavigationComponent.new(
items: secondary_items(request.path, @organisation.id),
level: "sub"
) %>
</div>
<div class="govuk-grid-column-two-thirds-from-desktop">
<%= govuk_summary_list do |summary_list| %>
<% @organisation.display_attributes.each do |attr| %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<% if can_edit_org?(current_user) && attr[:editable] || current_user.support? %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s.humanize } %>
<% row.value { details_html(attr) } %>

19
spec/requests/organisations_controller_spec.rb

@ -403,6 +403,25 @@ RSpec.describe OrganisationsController, type: :request do
expect(page).to have_content("About this organisation")
end
end
context "when viewing a specific organisation details" do
before do
get "/organisations/#{organisation.id}/details", headers:, params: {}
end
it "displays the name of the organisation" do
expect(page).to have_content(organisation.name)
end
it "has a sub-navigation with correct tabs" do
expect(page).to have_css(".app-sub-navigation")
expect(page).to have_content("About this organisation")
end
it "allows to edit the organisation details" do
expect(page).to have_link("Change", count: 10)
end
end
end
context "when there are more than 20 organisations" do

Loading…
Cancel
Save