Browse Source

Error prefix code review changes

pull/145/head
Matthew Phelan 3 years ago
parent
commit
84d8d6ee95
  1. 16
      app/helpers/application_helper.rb
  2. 8
      app/views/layouts/application.html.erb

16
app/helpers/application_helper.rb

@ -1,5 +1,21 @@
module ApplicationHelper module ApplicationHelper
def browser_title(title) def browser_title(title)
if user_log_errors || case_log_errors || resource_errors
["Error", title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ")
else
[title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ") [title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ")
end end
end end
def user_log_errors
@user.present? && @user.errors.present?
end
def case_log_errors
@case_log.present? && @case_log.errors.present?
end
def resource_errors
@resource.present? && @resource.errors.present?
end
end

8
app/views/layouts/application.html.erb

@ -1,15 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" class="govuk-template"> <html lang="en" class="govuk-template">
<head> <head>
<% if @resource.present? && @resource.errors.present? %>
<title><%= browser_title("Error: #{yield(:title)}") %></title>
<% elsif @user.present? && @user.errors.present? %>
<title><%= browser_title("Error: #{yield(:title)}") %></title>
<% elsif @case_log.present? && @case_log.errors.present?%>
<title><%= browser_title("Error: #{yield(:title)}") %></title>
<% else %>
<title><%= browser_title(yield(:title)) %></title> <title><%= browser_title(yield(:title)) %></title>
<% end %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= csp_meta_tag %> <%= csp_meta_tag %>
<%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %> <%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %>

Loading…
Cancel
Save