From 37298e1875d1e407e61f8a0a9bf70b8bf69ead7f Mon Sep 17 00:00:00 2001 From: J G <7750475+moarpheus@users.noreply.github.com> Date: Wed, 8 Jun 2022 13:36:17 +0100 Subject: [PATCH] headings partial (#645) * mopped headings * show page dry logic * dry headings logic --- app/views/case_logs/index.html.erb | 7 +------ app/views/organisations/_headings.html.erb | 4 ++++ app/views/organisations/index.html.erb | 12 +----------- app/views/organisations/logs.html.erb | 4 +--- app/views/organisations/show.html.erb | 9 +-------- app/views/organisations/users.html.erb | 4 +--- app/views/users/index.html.erb | 7 +------ 7 files changed, 10 insertions(+), 37 deletions(-) create mode 100644 app/views/organisations/_headings.html.erb diff --git a/app/views/case_logs/index.html.erb b/app/views/case_logs/index.html.erb index 82fd29188..583eac968 100644 --- a/app/views/case_logs/index.html.erb +++ b/app/views/case_logs/index.html.erb @@ -3,12 +3,7 @@ <% content_for :title, title %> -

- <% unless current_user.support? %> - <%= current_user.organisation.name %> - <% end %> - Logs -

+<%= render partial: "organisations/headings", locals: current_user.support? ? { main: "Logs", sub: nil } : { main: "Logs", sub: current_user.organisation.name } %>
diff --git a/app/views/organisations/_headings.html.erb b/app/views/organisations/_headings.html.erb new file mode 100644 index 000000000..6f601ecde --- /dev/null +++ b/app/views/organisations/_headings.html.erb @@ -0,0 +1,4 @@ +

+ <%= sub %> + <%= main %> +

diff --git a/app/views/organisations/index.html.erb b/app/views/organisations/index.html.erb index 0455c23ad..65f8134b7 100644 --- a/app/views/organisations/index.html.erb +++ b/app/views/organisations/index.html.erb @@ -3,17 +3,7 @@ <% content_for :title, title %> -

- <% if current_user.support? && request.path == "/organisations" %> - Organisations - <% end %> - <% if current_user.support? && request.path != "/organisations" %> - <%= @organisation.name %> -

Organisations

- <% end %> - - -<% items = tab_items(current_user) %> +<%= render partial: "organisations/headings", locals: request.path == "/organisations" ? { main: "Organisations", sub: nil } : { main: @organisation.name, sub: "Organisations" } %>

Organisations

diff --git a/app/views/organisations/logs.html.erb b/app/views/organisations/logs.html.erb index ee476a59d..a12ef6a32 100644 --- a/app/views/organisations/logs.html.erb +++ b/app/views/organisations/logs.html.erb @@ -3,9 +3,7 @@ <% content_for :title, title %> -

- <%= @organisation.name %> -

+<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new( items: secondary_items(request.path, @organisation.id), diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb index f19e76c1e..5b82aedc7 100644 --- a/app/views/organisations/show.html.erb +++ b/app/views/organisations/show.html.erb @@ -2,14 +2,7 @@ <% title = format_title(nil, current_user.support? ? "About this organisation" : "About your organisation", current_user, nil, nil, @organisation.name) %> <% content_for :title, title %> -

- <% if !current_user.support? %> - <%= current_user.organisation.name %> - About your organisation - <% else %> - <%= @organisation.name %> - <% end %> -

+<%= render partial: "organisations/headings", locals: current_user.support? ? { main: @organisation.name, sub: nil } : { main: "About your organisation", sub: current_user.organisation.name } %> <% if current_user.support? %> <%= render SubNavigationComponent.new( diff --git a/app/views/organisations/users.html.erb b/app/views/organisations/users.html.erb index 918331435..d7a889b2e 100644 --- a/app/views/organisations/users.html.erb +++ b/app/views/organisations/users.html.erb @@ -3,9 +3,7 @@ <% content_for :title, title %> -

- <%= @organisation.name %> -

+<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new( items: secondary_items(request.path, @organisation.id), diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index b9c76e8e5..3444479c2 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -3,12 +3,7 @@ <% content_for :title, title %> -

- <% unless current_user.support? %> - <%= current_user.organisation.name %> - <% end %> - Users -

+<%= render partial: "organisations/headings", locals: current_user.support? ? { main: "Users", sub: nil } : { main: "User", sub: current_user.organisation.name } %>

Users