-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4275 from DFE-Digital/1734-bug-copy-content-drop-…
…down-disappears-after-validation [1734] bug copy content drop down disappears after validation, broken links in copy content warning
- Loading branch information
Showing
25 changed files
with
482 additions
and
128 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/components/providers/copy_course_content_warning_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<% if field_links.present? %> | ||
<%= govuk_notification_banner( | ||
title_text: t("notification_banner.warning"), | ||
classes: "govuk-notification-banner--warning", | ||
html_attributes: { | ||
data: { qa: "copy-course-warning" }, | ||
role: "alert" | ||
} | ||
) do |notification_banner| %> | ||
<% notification_banner.with_heading( | ||
text: t("components.providers.copy_course_content_warning_component.changes_not_saved") | ||
) %> | ||
<p class="govuk-body"> | ||
<%= copied_fields_from %> | ||
</p> | ||
<ul class="govuk-list"> | ||
<% field_links.each do |name, target| %> | ||
<li><%= govuk_link_to name, target, class: "govuk-notification-banner__link" %></li> | ||
<% end %> | ||
</ul> | ||
<p class="govuk-body"><%= please_check_changes %></p> | ||
<% end %> | ||
<% end %> |
35 changes: 35 additions & 0 deletions
35
app/components/providers/copy_course_content_warning_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Providers | ||
class CopyCourseContentWarningComponent < ApplicationComponent | ||
def initialize(copied_fields, form_identifier, source_course, **) | ||
super(**) | ||
@copied_fields = copied_fields | ||
@form_identifier = form_identifier | ||
@source_course = source_course | ||
end | ||
|
||
def field_links | ||
@copied_fields.map do |name, field| | ||
[name, "##{@form_identifier}-#{field.gsub('_', '-')}-field"] | ||
end | ||
end | ||
|
||
def please_check_changes | ||
translation_base = 'components.providers.copy_course_content_warning_component.please_check_changes' | ||
I18n.t("#{translation_base}.#{plural? ? 'plural' : 'singular'}") | ||
end | ||
|
||
def copied_fields_from | ||
translation_base = 'components.providers.copy_course_content_warning_component.copied_fields_from' | ||
I18n.t( | ||
"#{translation_base}.#{plural? ? 'plural' : 'singular'}", | ||
name_and_code: "#{@source_course.name} (#{@source_course.course_code})" | ||
) | ||
end | ||
|
||
def plural? | ||
@copied_fields.length > 1 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ def update | |
|
||
redirect_to redirect_path | ||
else | ||
fetch_course_list_to_copy_from | ||
render :edit | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ def update | |
|
||
redirect_to redirect_path | ||
else | ||
fetch_course_list_to_copy_from | ||
render :edit | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
app/views/publish/courses/about_this_course/_copy_about_course_content_warning.html.erb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
app/views/publish/courses/interview_process/_copy_interview_process_content_warning.html.erb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
app/views/publish/courses/school_placements/_copy_school_placements_content_warning.html.erb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
spec/components/providers/copy_course_content_warning_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Providers | ||
class CopyCourseContentWarningComponentPreview < ViewComponent::Preview | ||
def with_many_fields | ||
source_course = Course.new(name: 'Course name', course_code: 'AFGT') | ||
copied_fields = [ | ||
['About this course', 'about_this_course'], | ||
['How placements work', 'how_placements_work'] | ||
] | ||
render( | ||
CopyCourseContentWarningComponent.new( | ||
copied_fields, | ||
'form-identifier', | ||
source_course | ||
) | ||
) | ||
end | ||
|
||
def with_one_field | ||
source_course = Course.new(name: 'Course name', course_code: 'AFGT') | ||
copied_fields = [['How placements work', 'how_placements_work']] | ||
render( | ||
CopyCourseContentWarningComponent.new( | ||
copied_fields, | ||
'form-identifier', | ||
source_course | ||
) | ||
) | ||
end | ||
end | ||
end |
Oops, something went wrong.