4 changed files with 39 additions and 12 deletions
@ -1,11 +1,20 @@
|
||||
module ApplicationHelper |
||||
include Pagy::Frontend |
||||
|
||||
def browser_title(title, *resources) |
||||
def browser_title(title, pagy, *resources) |
||||
if resources.any? { |r| r.present? && r.errors.present? } |
||||
"Error: #{[title, t('service_name'), 'GOV.UK'].select(&:present?).join(' - ')}" |
||||
else |
||||
[title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ") |
||||
[paginated_title(title, pagy), t("service_name"), "GOV.UK"].select(&:present?).join(" - ") |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def paginated_title(title, pagy) |
||||
return unless title |
||||
return title unless pagy && pagy.pages > 1 |
||||
|
||||
title + " (page #{pagy.page} of #{pagy.pages})" |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue