govuk_publishing_components 24.3.0 → 24.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/details.js +1 -1
  3. data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +108 -0
  4. data/app/assets/javascripts/govuk_publishing_components/components/show-password.js +7 -2
  5. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +6 -2
  6. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -1
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +11 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +8 -1
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +117 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +17 -13
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +12 -0
  13. data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
  14. data/app/models/govuk_publishing_components/audit_comparer.rb +2 -2
  15. data/app/models/govuk_publishing_components/component_example.rb +4 -3
  16. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +8 -5
  17. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
  18. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +6 -6
  19. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +1 -1
  20. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  21. data/app/views/govuk_publishing_components/components/_list.html.erb +5 -5
  22. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  23. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +1 -1
  25. data/app/views/govuk_publishing_components/components/_radio.html.erb +2 -1
  26. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +45 -0
  27. data/app/views/govuk_publishing_components/components/_search.html.erb +27 -16
  28. data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
  29. data/app/views/govuk_publishing_components/components/_show_password.html.erb +6 -4
  30. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +1 -1
  31. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  32. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +73 -31
  34. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  36. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +1 -1
  37. data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +22 -0
  38. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +1 -1
  39. data/app/views/govuk_publishing_components/components/docs/radio.yml +14 -1
  40. data/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +85 -0
  41. data/app/views/govuk_publishing_components/components/docs/search.yml +10 -0
  42. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +33 -19
  43. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +2 -0
  44. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +17 -3
  45. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -2
  46. data/config/locales/en.yml +25 -15
  47. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +2 -1
  48. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -1
  49. data/lib/govuk_publishing_components/presenters/machine_readable/html_publication_schema.rb +1 -7
  50. data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -2
  51. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +2 -2
  52. data/lib/govuk_publishing_components/version.rb +1 -1
  53. data/lib/tasks/govuk_publishing_components_tasks.rake +1 -1
  54. data/node_modules/sortablejs/LICENSE +21 -0
  55. data/node_modules/sortablejs/README.md +815 -0
  56. data/node_modules/sortablejs/Sortable.js +3721 -0
  57. data/node_modules/sortablejs/Sortable.min.js +2 -0
  58. data/node_modules/sortablejs/modular/sortable.complete.esm.js +3713 -0
  59. data/node_modules/sortablejs/modular/sortable.core.esm.js +3710 -0
  60. data/node_modules/sortablejs/modular/sortable.esm.js +3711 -0
  61. data/node_modules/sortablejs/package.json +56 -0
  62. metadata +19 -7
@@ -110,8 +110,8 @@ module GovukPublishingComponents
110
110
  next if second[:components].include?("all")
111
111
 
112
112
  in_current.each do |component|
113
- if @gem_data.include?("component_#{second_location}".to_sym)
114
- warnings << create_warning(component, "Included in #{first_location} but not #{second_location}") if @gem_data["component_#{second_location}".to_sym].include?(component)
113
+ if @gem_data.include?("component_#{second_location}".to_sym) && @gem_data["component_#{second_location}".to_sym].include?(component)
114
+ warnings << create_warning(component, "Included in #{first_location} but not #{second_location}")
115
115
  end
116
116
  end
117
117
  end
@@ -57,13 +57,14 @@ module GovukPublishingComponents
57
57
  # Safe HTML can be passed to components, simulate
58
58
  # by marking any string that comes from YAML as safe
59
59
  def html_safe_strings(obj)
60
- if obj.is_a?(String)
60
+ case obj
61
+ when String
61
62
  obj.html_safe
62
- elsif obj.is_a?(Hash)
63
+ when Hash
63
64
  obj.each do |key, value|
64
65
  obj[key] = html_safe_strings(value)
65
66
  end
66
- elsif obj.is_a?(Array)
67
+ when Array
67
68
  obj.map! { |e| html_safe_strings(e) }
68
69
  else
69
70
  obj
@@ -1,19 +1,22 @@
1
1
  <%
2
+ border ||= false
2
3
  breadcrumbs ||= []
3
- inverse ||= false
4
4
  collapse_on_mobile ||= false
5
+ inverse ||= false
6
+
5
7
  breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs)
6
8
 
7
- classes = "gem-c-breadcrumbs govuk-breadcrumbs"
8
- classes << " govuk-breadcrumbs--collapse-on-mobile" if collapse_on_mobile
9
- classes << " gem-c-breadcrumbs--inverse" if inverse
9
+ classes = %w[gem-c-breadcrumbs govuk-breadcrumbs]
10
+ classes << "govuk-breadcrumbs--collapse-on-mobile" if collapse_on_mobile
11
+ classes << "gem-c-breadcrumbs--inverse" if inverse
12
+ classes << "gem-c-breadcrumbs--border-bottom" if border == "bottom"
10
13
  %>
11
14
 
12
15
  <script type="application/ld+json">
13
16
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
14
17
  </script>
15
18
 
16
- <div class="<%= classes %>" data-module="track-click">
19
+ <div class="<%= classes.join(" ") %>" data-module="gem-track-click">
17
20
  <ol class="govuk-breadcrumbs__list">
18
21
  <% breadcrumbs.each_with_index do |crumb, index| %>
19
22
  <% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %>
@@ -15,7 +15,7 @@
15
15
  "aria-label": aria_label,
16
16
  role: "navigation",
17
17
  data: {
18
- module: "track-click"
18
+ module: "gem-track-click"
19
19
  }
20
20
  ) do %>
21
21
  <%= content_tag(
@@ -14,7 +14,7 @@
14
14
  text = raw(text)
15
15
 
16
16
  cookie_preferences_href ||= "/help/cookies"
17
- confirmation_message ||= raw("You can <a class='govuk-link' href='#{cookie_preferences_href}' data-module='track-click' data-track-category='cookieBanner' data-track-action='Cookie banner settings clicked from confirmation'>change your cookie settings</a> at any time.")
17
+ confirmation_message ||= raw("You can <a class='govuk-link' href='#{cookie_preferences_href}' data-module='gem-track-click' data-track-category='cookieBanner' data-track-action='Cookie banner settings clicked from confirmation'>change your cookie settings</a> at any time.")
18
18
  services_cookies ||= nil
19
19
  css_classes = %w(gem-c-cookie-banner govuk-clearfix)
20
20
  css_classes << "gem-c-cookie-banner--services" if services_cookies
@@ -35,12 +35,12 @@
35
35
  <%= render "govuk_publishing_components/components/button", {
36
36
  name: "cookies",
37
37
  text: services_cookies.dig(:yes, :text) || "Yes",
38
- data_attributes: { module: "track-click", "accept-cookies": "true", }.merge(services_cookies.dig(:yes, :data_attributes) || {})
38
+ data_attributes: { module: "gem-track-click", "accept-cookies": "true", }.merge(services_cookies.dig(:yes, :data_attributes) || {})
39
39
  } %>
40
40
  <%= render "govuk_publishing_components/components/button", {
41
41
  name: "cookies",
42
42
  text: services_cookies.dig(:no, :text) || "No",
43
- data_attributes: { module: "track-click", "reject-cookies": "true", }.merge(services_cookies.dig(:no, :data_attributes) || {})
43
+ data_attributes: { module: "gem-track-click", "reject-cookies": "true", }.merge(services_cookies.dig(:no, :data_attributes) || {})
44
44
  } %>
45
45
  <% if services_cookies[:cookie_preferences] %>
46
46
  <%= link_to services_cookies.dig(:cookie_preferences, :text), services_cookies.dig(:cookie_preferences, :href), class: "govuk-link" %>
@@ -52,7 +52,7 @@
52
52
  name: "cookies",
53
53
  text: "Accept additional cookies",
54
54
  data_attributes: {
55
- module: "track-click",
55
+ module: "gem-track-click",
56
56
  "accept-cookies": "true",
57
57
  "track-category": "cookieBanner",
58
58
  "track-action": "Cookie banner accepted",
@@ -63,7 +63,7 @@
63
63
  name: "cookies",
64
64
  text: "Reject additional cookies",
65
65
  data_attributes: {
66
- module: "track-click",
66
+ module: "gem-track-click",
67
67
  "reject-cookies": "true",
68
68
  "track-category": "cookieBanner",
69
69
  "track-action": "Cookie banner rejected",
@@ -77,7 +77,7 @@
77
77
  <div class="gem-c-cookie-banner__confirmation govuk-width-container" tabindex="-1" hidden>
78
78
  <p class="gem-c-cookie-banner__confirmation-message" role="alert"><%= confirmation_message %></p>
79
79
  <div class="govuk-button-group">
80
- <button class="gem-c-cookie-banner__hide-button govuk-button" data-hide-cookie-banner="true" data-module="track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner">Hide this message</button>
80
+ <button class="gem-c-cookie-banner__hide-button govuk-button" data-hide-cookie-banner="true" data-module="gem-track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner">Hide this message</button>
81
81
  </div>
82
82
  </div>
83
83
  </div>
@@ -9,7 +9,7 @@
9
9
  %>
10
10
  <% if items.any? %>
11
11
  <% unless within_multitype_list %>
12
- <ol class="gem-c-highlight-boxes" <%= "data-module=track-click" if highlight_boxes_helper.data_tracking? %>>
12
+ <ol class="gem-c-highlight-boxes" <%= "data-module=gem-track-click" if highlight_boxes_helper.data_tracking? %>>
13
13
  <% end %>
14
14
  <% items.each do |content_item| %>
15
15
  <li class="gem-c-highlight-boxes__item-wrapper <%= half_width_class %>">
@@ -9,7 +9,7 @@
9
9
  %>
10
10
  <% if card_helper.href || card_helper.extra_links.any? %>
11
11
  <div class="<%= classes %> <%= brand_helper.brand_class %>"
12
- <%= "data-module=track-click" if card_helper.is_tracking? %>
12
+ <%= "data-module=gem-track-click" if card_helper.is_tracking? %>
13
13
  <%= "lang=#{card_helper.lang}" if card_helper.lang %>>
14
14
  <div class="gem-c-image-card__text-wrapper">
15
15
  <div class="gem-c-image-card__header-and-context-wrapper">
@@ -1,12 +1,12 @@
1
1
  <%
2
- id ||= nil
2
+ aria_label ||= nil
3
3
  extra_spacing ||= nil
4
+ id ||= nil
5
+ items ||= []
4
6
  list_type ||= "unordered"
5
7
  visible_counters ||= nil
6
- items ||= []
7
- aria_label ||= nil
8
8
 
9
- classes = %w(gem-c-list govuk-list)
9
+ classes = %w[gem-c-list govuk-list]
10
10
  classes << "govuk-list--bullet" if visible_counters && list_type === "unordered"
11
11
  classes << "govuk-list--number" if visible_counters && list_type === "number"
12
12
  classes << "govuk-list--spaced" if extra_spacing
@@ -20,7 +20,7 @@
20
20
  <% if items.any? %>
21
21
  <%= content_tag list_tag, class: classes, id: id, "aria-label": aria_label do %>
22
22
  <% items.each do |item| %>
23
- <li><%= sanitize(item) %></li>
23
+ <li><%= raw(item) %></li>
24
24
  <% end %>
25
25
  <% end %>
26
26
  <% end %>
@@ -16,7 +16,7 @@
16
16
  classes << "gem-c-metadata--inverse" if inverse
17
17
  %>
18
18
  <%= content_tag :div, class: classes, data: { module: "gem-toggle" } do %>
19
- <dl data-module="track-click">
19
+ <dl data-module="gem-track-click">
20
20
  <% if from.any? %>
21
21
  <dt class="gem-c-metadata__term"><%= t("govuk_component.metadata.from", default: "From") %>:</dt>
22
22
  <dd class="gem-c-metadata__definition">
@@ -26,7 +26,7 @@
26
26
  %>
27
27
  <<%= wrapping_element %>
28
28
  class="<%= wrapper_classes.join(" ") %>"
29
- <%= "data-module=track-click" if organisation[:data_attributes] %>
29
+ <%= "data-module=gem-track-click" if organisation[:data_attributes] %>
30
30
  >
31
31
  <% if organisation[:url] %>
32
32
  <%= link_to organisation[:url],
@@ -4,7 +4,7 @@
4
4
  role="navigation"
5
5
  aria-label="<%= t("govuk_component.previous_and_next_navigation.pagination", default: "Pagination") %>"
6
6
  >
7
- <ul class="gem-c-pagination__list" data-module="track-click">
7
+ <ul class="gem-c-pagination__list" data-module="gem-track-click">
8
8
  <% if local_assigns.include?(:previous_page) %>
9
9
  <li class="gem-c-pagination__item gem-c-pagination__item--previous">
10
10
  <a href="<%= previous_page[:url] %>"
@@ -1,4 +1,5 @@
1
1
  <%
2
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
2
3
  id ||= nil
3
4
  id_prefix ||= "radio-#{SecureRandom.hex(4)}"
4
5
  items ||= []
@@ -54,7 +55,7 @@
54
55
  <% end %>
55
56
  <% else %>
56
57
  <%= tag.legend class: legend_classes do %>
57
- <%= tag.h2 heading, class: "govuk-fieldset__heading" %>
58
+ <%= content_tag(shared_helper.get_heading_level, heading, class: "govuk-fieldset__heading") %>
58
59
  <% end %>
59
60
  <% end %>
60
61
  <% end %>
@@ -0,0 +1,45 @@
1
+ <%
2
+ items ||= []
3
+ input_name ||= "ordering"
4
+ data_attributes ||= {}
5
+ data_attributes[:module] = "reorderable-list"
6
+ %>
7
+
8
+ <%= tag.ol class: "gem-c-reorderable-list", data: data_attributes do %>
9
+ <% items.each_with_index do |item, index| %>
10
+ <%= tag.li class: "gem-c-reorderable-list__item" do %>
11
+ <%= tag.div class: "gem-c-reorderable-list__wrapper" do %>
12
+ <%= tag.div class: "gem-c-reorderable-list__content" do %>
13
+ <%= tag.p item[:title], class: "gem-c-reorderable-list__title" %>
14
+ <%= tag.p(item[:description], class: "gem-c-reorderable-list__description") if item[:description].present? %>
15
+ <% end %>
16
+ <%= tag.div class: "gem-c-reorderable-list__actions" do %>
17
+ <% label_text = capture do %>
18
+ Position<span class='govuk-visually-hidden'> for <%= item[:title] %></span>
19
+ <% end %>
20
+ <%= render "govuk_publishing_components/components/input", {
21
+ label: { text: label_text },
22
+ name: "#{input_name}[#{item[:id]}]",
23
+ type: "number",
24
+ value: index + 1,
25
+ width: 2
26
+ } %>
27
+ <%= render "govuk_publishing_components/components/button", {
28
+ text: "Up",
29
+ type: "button",
30
+ aria_label: "Move \"#{item[:title]}\" up",
31
+ classes: "js-reorderable-list-up",
32
+ secondary_solid: true
33
+ } %>
34
+ <%= render "govuk_publishing_components/components/button", {
35
+ text: "Down",
36
+ type: "button",
37
+ aria_label: "Move \"#{item[:title]}\" down",
38
+ classes: "js-reorderable-list-down",
39
+ secondary_solid: true
40
+ } %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+ <% end %>
@@ -1,11 +1,19 @@
1
1
  <%
2
- size ||= ""
3
- no_border ||= false
4
2
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
5
- classes = %w(gem-c-search)
3
+
4
+ aria_controls ||= nil
5
+ button_text ||= t("components.search_box.search_button")
6
+ id ||= "search-main-" + SecureRandom.hex(4)
7
+ label_text ||= t("components.search_box.label")
8
+ name ||= "q"
9
+ no_border ||= false
10
+ size ||= ""
11
+ value ||= ""
12
+
13
+ classes = %w[gem-c-search]
6
14
  classes << (shared_helper.get_margin_top)
7
15
  classes << (shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
8
- classes << "gem-c-search--large" if size == 'large'
16
+ classes << "gem-c-search--large" if size == "large"
9
17
  classes << "gem-c-search--no-border" if no_border
10
18
  if local_assigns[:on_govuk_blue].eql?(true)
11
19
  classes << "gem-c-search--on-govuk-blue"
@@ -13,25 +21,28 @@
13
21
  classes << "gem-c-search--on-white"
14
22
  end
15
23
  classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label)
16
-
17
- value ||= ""
18
- id ||= "search-main-" + SecureRandom.hex(4)
19
- label_text ||= "Search on GOV.UK"
20
- name ||= 'q'
21
- aria_controls ||= nil
22
24
  %>
23
25
 
24
- <div class="<%= classes.join(' ') %>" data-module="gem-toggle-input-class-on-focus">
26
+ <div class="<%= classes.join(" ") %>" data-module="gem-toggle-input-class-on-focus">
25
27
  <label for="<%= id %>" class="gem-c-search__label">
26
28
  <%= label_text %>
27
29
  </label>
28
30
  <div class="gem-c-search__item-wrapper">
29
- <input type="search" value="<%= value %>"
30
- id="<%= id %>" name="<%= name %>" title="Search"
31
- aria-controls="<%= aria_controls %>"
32
- class="gem-c-search__item gem-c-search__input js-class-toggle">
31
+ <%= tag.input(
32
+ aria: {
33
+ controls: aria_controls,
34
+ },
35
+ class: "gem-c-search__item gem-c-search__input js-class-toggle",
36
+ id: id,
37
+ name: name,
38
+ title: t("components.search_box.input_title"),
39
+ type: "search",
40
+ value: value,
41
+ ) %>
33
42
  <div class="gem-c-search__item gem-c-search__submit-wrapper">
34
- <button type="submit" class="gem-c-search__submit">Search</button>
43
+ <button class="gem-c-search__submit" type="submit">
44
+ <%= button_text %>
45
+ </button>
35
46
  </div>
36
47
  </div>
37
48
  </div>
@@ -14,7 +14,7 @@
14
14
  classes << brand_helper.brand_class
15
15
 
16
16
  data_attributes ||= {}
17
- data_attributes[:module] = 'track-click'
17
+ data_attributes[:module] = 'gem-track-click'
18
18
  %>
19
19
  <% if links.any? %>
20
20
  <%= tag.div(class: classes, data: data_attributes) do %>
@@ -19,10 +19,12 @@
19
19
  data: {
20
20
  module: "show-password",
21
21
  disable_form_submit_check: disable_form_submit_check,
22
- show: t('components.input.show'),
23
- hide: t('components.input.hide'),
24
- announce_show: t('components.input.announce_show'),
25
- announce_hide: t('components.input.announce_hide')
22
+ show_text: t('components.show_password.show'),
23
+ hide_text: t('components.show_password.hide'),
24
+ show_full_text: t('components.show_password.show_password'),
25
+ hide_full_text: t('components.show_password.hide_password'),
26
+ announce_show: t('components.show_password.announce_show'),
27
+ announce_hide: t('components.show_password.announce_hide')
26
28
  } do %>
27
29
  <%= render "govuk_publishing_components/components/input", {
28
30
  label: label,
@@ -28,7 +28,7 @@
28
28
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
29
29
  </script>
30
30
 
31
- <h2 class="<%= classes %>" data-module="track-click">
31
+ <h2 class="<%= classes %>" data-module="gem-track-click">
32
32
  <span class="gem-c-step-nav-header__part-of">Part of</span>
33
33
  <% if path %>
34
34
  <a href="<%= path %>"
@@ -6,7 +6,7 @@
6
6
  <% if links.any? %>
7
7
  <div
8
8
  class="gem-c-step-nav-related <%= "gem-c-step-nav-related--singular" if links.length == 1 %>"
9
- data-module="track-click">
9
+ data-module="gem-track-click">
10
10
  <h2 class="gem-c-step-nav-related__heading">
11
11
  <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
12
12
  <% if links.length == 1 && !always_display_as_list %>
@@ -27,7 +27,7 @@
27
27
  <% end %>
28
28
  <ul
29
29
  class="gem-c-subscription-links__list<%= ' gem-c-subscription-links__list--small' if local_assigns[:small_form] == true %>"
30
- <%= "data-module=track-click" if sl_helper.tracking_is_present? %>
30
+ <%= "data-module=gem-track-click" if sl_helper.tracking_is_present? %>
31
31
  >
32
32
  <% if sl_helper.email_signup_link.present? %>
33
33
  <li class="gem-c-subscription-links__list-item<%= ' gem-c-subscription-links__list-item--small' if local_assigns[:small_form] == true %>" >
@@ -10,37 +10,59 @@
10
10
  delete ||= {}
11
11
  items ||= []
12
12
  block ||= yield
13
+ wide_title ||= false
13
14
  %>
14
15
  <% if title || items.any? %>
15
- <%= tag.div class: "gem-c-summary-list #{"govuk-summary-list--no-border" if borderless}", id: id do %>
16
+ <%= tag.div class: "gem-c-summary-list #{"govuk-summary-list--no-border" if borderless} #{"gem-c-summary-list--wide-title" if wide_title}", id: id do %>
16
17
  <% if title %>
17
18
  <%= content_tag(shared_helper.get_heading_level, title, class: "govuk-heading-#{heading_size} gem-c-summary-list__group-title") %>
18
- <% if edit.any? || delete.any? %>
19
+
20
+ <% if edit.any? %>
21
+ <% edit_main_link = capture do %>
22
+ <%
23
+ edit_section_link_text = edit[:link_text] || t("components.summary_list.edit")
24
+ %>
25
+ <%= link_to edit.fetch(:href),
26
+ class: "govuk-link",
27
+ data: edit.fetch(:data_attributes, {}) do %>
28
+ <%= edit_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" unless edit[:link_text_no_enhance] -%>
29
+ <% end %>
30
+ <% end %>
31
+ <% end %>
32
+
33
+ <% if delete.any? %>
34
+ <% delete_main_link = capture do %>
35
+ <%
36
+ delete_section_link_text = delete[:link_text] || t("components.summary_list.delete")
37
+ %>
38
+ <%= link_to delete.fetch(:href),
39
+ class: "govuk-link gem-link--destructive",
40
+ data: delete.fetch(:data_attributes, {}) do %>
41
+ <%= delete_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" unless delete[:link_text_no_enhance] -%>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+
46
+ <% if edit_main_link && delete_main_link %>
19
47
  <%= tag.ul class: "govuk-summary-list__actions-list gem-c-summary-list__group-actions-list" do %>
20
48
  <%- if edit.any? %>
21
- <% edit_section_link_text = edit[:link_text] || t("components.summary_list.edit") %>
22
49
  <%= tag.li class: "govuk-summary-list__actions-list-item" do -%>
23
- <%= link_to edit.fetch(:href),
24
- class: "govuk-link",
25
- title: "#{edit_section_link_text} #{title}",
26
- data: edit.fetch(:data_attributes, {}) do %>
27
- <%= edit_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" -%>
28
- <% end %>
50
+ <%= edit_main_link %>
29
51
  <% end %>
30
52
  <% end %>
31
53
  <% if delete.any? %>
32
- <% delete_section_link_text = delete[:link_text] || t("components.summary_list.delete") %>
33
54
  <%= tag.li class: "govuk-summary-list__actions-list-item" do -%>
34
- <%= link_to delete.fetch(:href),
35
- class: "govuk-link gem-link--destructive",
36
- title: "#{delete_section_link_text} #{title}",
37
- data: delete.fetch(:data_attributes, {}) do %>
38
- <%= delete_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" -%>
39
- <% end %>
55
+ <%= delete_main_link %>
40
56
  <% end %>
41
57
  <% end %>
42
58
  <% end %>
59
+ <% else %>
60
+ <%= tag.div class: "govuk-summary-list__actions-list gem-c-summary-list__group-actions-list" do %>
61
+ <%= edit_main_link %>
62
+ <%= delete_main_link %>
63
+ <% end %>
43
64
  <% end %>
65
+
44
66
  <% end %>
45
67
 
46
68
  <% if items.any? %>
@@ -51,34 +73,54 @@
51
73
  <%= tag.dt item[:field], class: "govuk-summary-list__key" %>
52
74
  <%= tag.dd item[:value], class: "govuk-summary-list__value" %>
53
75
 
54
- <% if item.fetch(:edit, {}).any? || item.fetch(:delete, {}).any? %>
76
+ <% if item.fetch(:edit, {}).any? %>
77
+ <% edit_link = capture do %>
78
+ <%
79
+ edit_link_text = item[:edit][:link_text] || t("components.summary_list.edit")
80
+ %>
81
+ <%= link_to item[:edit].fetch(:href),
82
+ class: "govuk-link",
83
+ data: item[:edit].fetch(:data_attributes, {}) do %>
84
+ <%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" unless edit[:link_text_no_enhance] -%>
85
+ <% end %>
86
+ <% end %>
87
+ <% end %>
88
+
89
+ <% if item.fetch(:delete, {}).any? %>
90
+ <% delete_link = capture do %>
91
+ <%
92
+ delete_link_text = item[:delete][:link_text] || t("components.summary_list.delete")
93
+ %>
94
+ <%= link_to item[:delete].fetch(:href),
95
+ class: "govuk-link gem-link--destructive",
96
+ data: item[:delete].fetch(:data_attributes, {}) do %>
97
+ <%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" unless delete[:link_text_no_enhance] -%>
98
+ <% end %>
99
+ <% end %>
100
+ <% end %>
101
+
102
+ <% if edit_link && delete_link %>
55
103
  <%= tag.dd class: "govuk-summary-list__actions" do %>
56
104
  <%= tag.ul class: "govuk-summary-list__actions-list" do %>
57
105
  <% if item.fetch(:edit, {}).any? %>
58
106
  <%= tag.li class: "govuk-summary-list__actions-list-item" do %>
59
- <% edit_link_text = item[:edit][:link_text] || t("components.summary_list.edit") %>
60
- <%= link_to item[:edit].fetch(:href),
61
- class: "govuk-link",
62
- title: "#{edit_link_text} #{item[:field]}",
63
- data: item[:edit].fetch(:data_attributes, {}) do %>
64
- <%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" -%>
65
- <% end %>
107
+ <%= edit_link %>
66
108
  <% end %>
67
109
  <% end %>
68
110
  <% if item.fetch(:delete, {}).any? %>
69
111
  <%= tag.li class: "govuk-summary-list__actions-list-item" do %>
70
- <% delete_link_text = item[:delete][:link_text] || t("components.summary_list.delete") %>
71
- <%= link_to item[:delete].fetch(:href),
72
- class: "govuk-link gem-link--destructive",
73
- title: "#{delete_link_text} #{item[:field]}",
74
- data: item[:delete].fetch(:data_attributes, {}) do %>
75
- <%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" -%>
76
- <% end %>
112
+ <%= delete_link %>
77
113
  <% end %>
78
114
  <% end %>
79
115
  <% end %>
80
116
  <% end %>
117
+ <% else %>
118
+ <%= tag.dd class: "govuk-summary-list__actions" do %>
119
+ <%= edit_link %>
120
+ <%= delete_link %>
121
+ <% end %>
81
122
  <% end %>
123
+
82
124
  <% end %>
83
125
  <% end %>
84
126
  <% end %>