Browse Source

feat: give support users breadcrumbs to individual org obejcts for schemes, users and logs

pull/2031/head
natdeanlewissoftwire 1 year ago
parent
commit
e91de93c31
  1. 13
      app/helpers/tasklist_helper.rb
  2. 2
      app/views/logs/edit.html.erb
  3. 15
      app/views/schemes/show.html.erb
  4. 13
      app/views/users/show.html.erb

13
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

2
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) => "",
}) %>

15
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 } %>

13
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 %>
<div class="govuk-grid-row">

Loading…
Cancel
Save