Browse Source

feat: add user param to log breadcrumbs

pull/2031/head
natdeanlewissoftwire 1 year ago
parent
commit
e50bd7502c
  1. 18
      app/helpers/tasklist_helper.rb
  2. 2
      app/views/logs/edit.html.erb

18
app/helpers/tasklist_helper.rb

@ -2,14 +2,18 @@ module TasklistHelper
include GovukLinkHelper include GovukLinkHelper
include CollectionTimeHelper include CollectionTimeHelper
def breadcrumb_logs_title(log) def breadcrumb_logs_title(log, current_user)
log_type = log.lettings? ? "Lettings" : "Sales" log_type = log.lettings? ? "Lettings" : "Sales"
current_user.support? ? "#{log_type} logs (#{log.owning_organisation.name})" : "#{log_type} logs" if current_user.support? && breadcrumb_organisation(log).present?
"#{log_type} logs (#{breadcrumb_organisation(log).name})"
else
"#{log_type} logs"
end
end end
def breadcrumb_logs_link(log) def breadcrumb_logs_link(log, current_user)
if current_user.support? if current_user.support? && breadcrumb_organisation(log).present?
log.lettings? ? lettings_logs_organisation_path(@log.owning_organisation) : sales_logs_organisation_path(@log.owning_organisation) log.lettings? ? lettings_logs_organisation_path(breadcrumb_organisation(log)) : sales_logs_organisation_path(breadcrumb_organisation(log))
else else
log.lettings? ? lettings_logs_path : sales_logs_path log.lettings? ? lettings_logs_path : sales_logs_path
end end
@ -56,6 +60,10 @@ module TasklistHelper
private private
def breadcrumb_organisation(log)
log.owning_organisation || (log.managing_organisation if log.respond_to?(:managing_organisation))
end
def next_page_or_check_answers(subsection, log, current_user) def next_page_or_check_answers(subsection, log, current_user)
path = if subsection.is_started?(log) path = if subsection.is_started?(log)
"#{log.class.name.underscore}_#{subsection.id}_check_answers_path" "#{log.class.name.underscore}_#{subsection.id}_check_answers_path"

2
app/views/logs/edit.html.erb

@ -1,6 +1,6 @@
<% content_for :title, "Log #{@log.id}" %> <% content_for :title, "Log #{@log.id}" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
breadcrumb_logs_title(@log) => breadcrumb_logs_link(@log), breadcrumb_logs_title(@log, current_user) => breadcrumb_logs_link(@log, current_user),
content_for(:title) => "", content_for(:title) => "",
}) %> }) %>

Loading…
Cancel
Save