From e91de93c31d8a3107846c3554f8c996e339e8b9a Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 5 Dec 2023 10:56:55 +0000 Subject: [PATCH] feat: give support users breadcrumbs to individual org obejcts for schemes, users and logs --- app/helpers/tasklist_helper.rb | 13 +++++++++++++ app/views/logs/edit.html.erb | 2 +- app/views/schemes/show.html.erb | 15 +++++++++++---- app/views/users/show.html.erb | 13 +++++++++++-- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index dc587071e..c9b0f5549 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -2,6 +2,19 @@ module TasklistHelper include GovukLinkHelper include CollectionTimeHelper + def breadcrumb_logs_title(log) + log_type = log.lettings? ? "Lettings" : "Sales" + current_user.support? ? "#{log_type} logs (#{log.owning_organisation.name})" : "#{log_type} logs" + end + + def breadcrumb_logs_link(log) + if current_user.support? + log.lettings? ? lettings_logs_organisation_path(@log.owning_organisation) : sales_logs_organisation_path(@log.owning_organisation) + else + log.lettings? ? lettings_logs_path : sales_logs_path + end + end + def get_next_incomplete_section(log) log.form.subsections.find { |subsection| subsection.is_incomplete?(log) } end diff --git a/app/views/logs/edit.html.erb b/app/views/logs/edit.html.erb index 170aefe4d..3cfed5bc8 100644 --- a/app/views/logs/edit.html.erb +++ b/app/views/logs/edit.html.erb @@ -1,6 +1,6 @@ <% content_for :title, "Log #{@log.id}" %> <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { - "Logs" => @log.lettings? ? lettings_logs_path : sales_logs_path, + breadcrumb_logs_title(@log) => breadcrumb_logs_link(@log), content_for(:title) => "", }) %> diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index ec8c9021d..f3bc143cf 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -1,10 +1,17 @@ <% title = @scheme.service_name %> <% content_for :title, title %> -<% content_for :before_content do %> - <%= govuk_back_link( - href: "/schemes", - ) %> +<% if current_user.support? %> + <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { + "Schemes (#{@scheme.owning_organisation.name})" => schemes_organisation_path(@scheme.owning_organisation), + content_for(:title) => "", + }) %> +<% else %> + <% content_for :before_content do %> + <%= govuk_back_link( + href: schemes_path, + ) %> + <% end %> <% end %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index b4b4db85d..963dbf2c7 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,7 +1,16 @@ <% content_for :title, current_user == @user ? "Your account" : "#{@user.name.presence || @user.email}’s account" %> -<% content_for :before_content do %> - <%= govuk_back_link(href: :back) %> +<% if current_user.support? %> + <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { + "Users (#{@user.organisation.name})" => users_organisation_path(@user.organisation), + content_for(:title) => "", + }) %> +<% else %> + <% content_for :before_content do %> + <%= govuk_back_link( + href: users_path, + ) %> + <% end %> <% end %>