Compare commits

...

2 Commits

  1. 1
      app/controllers/form_controller.rb
  2. 14
      app/helpers/application_helper.rb
  3. 20
      app/views/layouts/application.html.erb

1
app/controllers/form_controller.rb

@ -25,6 +25,7 @@ class FormController < ApplicationController
updated_question = @page.questions.reject { |question| question.check_answer_label.blank? }.first updated_question = @page.questions.reject { |question| question.check_answer_label.blank? }.first
updated_question_string = [updated_question&.question_number_string, updated_question&.check_answer_label.to_s.downcase].compact.join(": ") updated_question_string = [updated_question&.question_number_string, updated_question&.check_answer_label.to_s.downcase].compact.join(": ")
flash[:notice] = "You have successfully updated #{updated_question_string}" flash[:notice] = "You have successfully updated #{updated_question_string}"
flash[:notification_banner_two_thirds] = true
end end
update_duplication_tracking update_duplication_tracking

14
app/helpers/application_helper.rb

@ -32,6 +32,20 @@ module ApplicationHelper
!request.path.match?(/\/notifications\/\d+$/) && (authenticated_user_has_notifications? || unauthenticated_user_has_notifications?) !request.path.match?(/\/notifications\/\d+$/) && (authenticated_user_has_notifications? || unauthenticated_user_has_notifications?)
end end
def notification_banner
govuk_notification_banner(
title_text: "Success",
success: true, title_heading_level: 3,
title_id: "flash-notice",
role: "alert",
) do |notification_banner|
notification_banner.with_heading(text: flash.notice.html_safe)
if flash[:notification_banner_body]
tag.p flash[:notification_banner_body]&.html_safe
end
end
end
private private
def paginated_title(title, pagy) def paginated_title(title, pagy)

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

@ -120,17 +120,15 @@
<main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing" id="main-content" role="main"> <main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing" id="main-content" role="main">
<% if flash.notice && !flash.notice.include?("translation missing") %> <% if flash.notice && !flash.notice.include?("translation missing") %>
<%= govuk_notification_banner( <% if flash[:notification_banner_two_thirds] %>
title_text: "Success", <div class="govuk-grid-row">
success: true, title_heading_level: 3, <div class="govuk-grid-column-two-thirds-from-desktop">
title_id: "flash-notice", <%= notification_banner %>
role: "alert" </div>
) do |notification_banner| </div>
notification_banner.with_heading(text: flash.notice.html_safe) <% else %>
if flash[:notification_banner_body] <%= notification_banner %>
tag.p flash[:notification_banner_body]&.html_safe <% end %>
end
end %>
<% end %> <% end %>
<%= content_for?(:content) ? yield(:content) : yield %> <%= content_for?(:content) ? yield(:content) : yield %>
</main> </main>

Loading…
Cancel
Save