govuk_publishing_components 24.4.1 → 24.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +108 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +6 -2
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +117 -0
- data/app/views/govuk_publishing_components/components/_list.html.erb +5 -5
- data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +45 -0
- data/app/views/govuk_publishing_components/components/_search.html.erb +27 -16
- data/app/views/govuk_publishing_components/components/_summary_list.html.erb +67 -30
- data/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +85 -0
- data/app/views/govuk_publishing_components/components/docs/search.yml +10 -0
- data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +17 -3
- data/config/locales/en.yml +24 -16
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/sortablejs/LICENSE +21 -0
- data/node_modules/sortablejs/README.md +815 -0
- data/node_modules/sortablejs/Sortable.js +3721 -0
- data/node_modules/sortablejs/Sortable.min.js +2 -0
- data/node_modules/sortablejs/modular/sortable.complete.esm.js +3713 -0
- data/node_modules/sortablejs/modular/sortable.core.esm.js +3710 -0
- data/node_modules/sortablejs/modular/sortable.esm.js +3711 -0
- data/node_modules/sortablejs/package.json +56 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b0fa1ddc43a2e926edce2c1f0417db5cbb0b1924caa41f91b817f3fc0d5647
|
4
|
+
data.tar.gz: 9e165fe5648aa0d6be420b8a00517c5295b58d5c6050b4b55646c8924272338f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75bb0f5311883c23c5b83cfb18cf619acc923fed727d174f4d72ea8cae9aacd99e1a701889b72779cc76d72b2596a2e0d4765fa8c11a150c01c7554f95e76719
|
7
|
+
data.tar.gz: 51c83f3aadc86d2ed048e34c739c4d2a976524855152890a392c1f633e8e371914bdf64525c6297c310b2855bd6062dddb80930923f994c61ca469dbbba88953
|
@@ -0,0 +1,108 @@
|
|
1
|
+
//= require sortablejs/Sortable.js
|
2
|
+
window.GOVUK = window.GOVUK || {}
|
3
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
4
|
+
|
5
|
+
(function (Modules) {
|
6
|
+
function ReorderableList () { }
|
7
|
+
|
8
|
+
ReorderableList.prototype.start = function ($module) {
|
9
|
+
this.$module = $module[0]
|
10
|
+
this.$upButtons = this.$module.querySelectorAll('.js-reorderable-list-up')
|
11
|
+
this.$downButtons = this.$module.querySelectorAll('.js-reorderable-list-down')
|
12
|
+
|
13
|
+
this.sortable = window.Sortable.create(this.$module, { // eslint-disable-line new-cap
|
14
|
+
chosenClass: 'gem-c-reorderable-list__item--chosen',
|
15
|
+
dragClass: 'gem-c-reorderable-list__item--drag',
|
16
|
+
onSort: function () {
|
17
|
+
this.updateOrderIndexes()
|
18
|
+
this.triggerEvent(this.$module, 'reorder-drag')
|
19
|
+
}.bind(this)
|
20
|
+
})
|
21
|
+
|
22
|
+
if (typeof window.matchMedia === 'function') {
|
23
|
+
this.setupResponsiveChecks()
|
24
|
+
} else {
|
25
|
+
this.sortable.option('disabled', true)
|
26
|
+
}
|
27
|
+
|
28
|
+
var boundOnClickUpButton = this.onClickUpButton.bind(this)
|
29
|
+
this.$upButtons.forEach(function (button) {
|
30
|
+
button.addEventListener('click', boundOnClickUpButton)
|
31
|
+
})
|
32
|
+
|
33
|
+
var boundOnClickDownButton = this.onClickDownButton.bind(this)
|
34
|
+
this.$downButtons.forEach(function (button) {
|
35
|
+
button.addEventListener('click', boundOnClickDownButton)
|
36
|
+
})
|
37
|
+
}
|
38
|
+
|
39
|
+
ReorderableList.prototype.setupResponsiveChecks = function () {
|
40
|
+
var tabletBreakpoint = '40.0625em' // ~640px
|
41
|
+
this.mediaQueryList = window.matchMedia('(min-width: ' + tabletBreakpoint + ')')
|
42
|
+
this.mediaQueryList.addListener(this.checkMode.bind(this))
|
43
|
+
this.checkMode()
|
44
|
+
}
|
45
|
+
|
46
|
+
ReorderableList.prototype.checkMode = function () {
|
47
|
+
this.sortable.option('disabled', !this.mediaQueryList.matches)
|
48
|
+
}
|
49
|
+
|
50
|
+
ReorderableList.prototype.onClickUpButton = function (e) {
|
51
|
+
var item = e.target.closest('.gem-c-reorderable-list__item')
|
52
|
+
var previousItem = item.previousElementSibling
|
53
|
+
if (item && previousItem) {
|
54
|
+
item.parentNode.insertBefore(item, previousItem)
|
55
|
+
this.updateOrderIndexes()
|
56
|
+
}
|
57
|
+
// if triggered by keyboard preserve focus on button
|
58
|
+
if (e.detail === 0) {
|
59
|
+
if (item !== item.parentNode.firstElementChild) {
|
60
|
+
e.target.focus()
|
61
|
+
} else {
|
62
|
+
e.target.nextElementSibling.focus()
|
63
|
+
}
|
64
|
+
}
|
65
|
+
this.triggerEvent(e.target, 'reorder-move-up')
|
66
|
+
}
|
67
|
+
|
68
|
+
ReorderableList.prototype.onClickDownButton = function (e) {
|
69
|
+
var item = e.target.closest('.gem-c-reorderable-list__item')
|
70
|
+
var nextItem = item.nextElementSibling
|
71
|
+
if (item && nextItem) {
|
72
|
+
item.parentNode.insertBefore(item, nextItem.nextElementSibling)
|
73
|
+
this.updateOrderIndexes()
|
74
|
+
}
|
75
|
+
// if triggered by keyboard preserve focus on button
|
76
|
+
if (e.detail === 0) {
|
77
|
+
if (item !== item.parentNode.lastElementChild) {
|
78
|
+
e.target.focus()
|
79
|
+
} else {
|
80
|
+
e.target.previousElementSibling.focus()
|
81
|
+
}
|
82
|
+
}
|
83
|
+
this.triggerEvent(e.target, 'reorder-move-down')
|
84
|
+
}
|
85
|
+
|
86
|
+
ReorderableList.prototype.updateOrderIndexes = function () {
|
87
|
+
var $orderInputs = this.$module.querySelectorAll('.gem-c-reorderable-list__actions input')
|
88
|
+
$orderInputs.forEach(function (input, index) {
|
89
|
+
input.setAttribute('value', index + 1)
|
90
|
+
})
|
91
|
+
}
|
92
|
+
|
93
|
+
ReorderableList.prototype.triggerEvent = function (element, eventName) {
|
94
|
+
var params = { bubbles: true, cancelable: true }
|
95
|
+
var event
|
96
|
+
|
97
|
+
if (typeof window.CustomEvent === 'function') {
|
98
|
+
event = new window.CustomEvent(eventName, params)
|
99
|
+
} else {
|
100
|
+
event = document.createEvent('CustomEvent')
|
101
|
+
event.initCustomEvent(eventName, params.bubbles, params.cancelable)
|
102
|
+
}
|
103
|
+
|
104
|
+
element.dispatchEvent(event)
|
105
|
+
}
|
106
|
+
|
107
|
+
Modules.ReorderableList = ReorderableList
|
108
|
+
})(window.GOVUK.Modules)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
/* eslint-disable no-var */
|
2
|
+
|
1
3
|
// used by the header navigation from govuk_template
|
2
4
|
|
3
5
|
(function () {
|
@@ -14,6 +16,8 @@
|
|
14
16
|
var targetClass = target.getAttribute('class') || ''
|
15
17
|
var sourceClass = this.getAttribute('class') || ''
|
16
18
|
var isSearchToggle = sourceClass.match('search-toggle')
|
19
|
+
var showText = this.getAttribute('data-show-text') || 'Show search'
|
20
|
+
var hideText = this.getAttribute('data-hide-text') || 'Hide search'
|
17
21
|
|
18
22
|
if (targetClass.indexOf('js-visible') !== -1) {
|
19
23
|
target.setAttribute('class', targetClass.replace(/(^|\s)js-visible(\s|$)/, ''))
|
@@ -23,12 +27,12 @@
|
|
23
27
|
if (sourceClass.indexOf('js-visible') !== -1) {
|
24
28
|
this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, ''))
|
25
29
|
if (isSearchToggle) {
|
26
|
-
this.innerText =
|
30
|
+
this.innerText = showText
|
27
31
|
}
|
28
32
|
} else {
|
29
33
|
this.setAttribute('class', sourceClass + ' js-visible')
|
30
34
|
if (isSearchToggle) {
|
31
|
-
this.innerText =
|
35
|
+
this.innerText = hideText
|
32
36
|
}
|
33
37
|
}
|
34
38
|
this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// This is the file that the application needs to include in order to use
|
2
2
|
// the components.
|
3
3
|
|
4
|
-
@import "
|
4
|
+
@import "govuk_frontend_support";
|
5
5
|
|
6
6
|
@import "components/print/accordion";
|
7
7
|
@import "components/print/attachment";
|
@@ -0,0 +1,117 @@
|
|
1
|
+
.gem-c-reorderable-list {
|
2
|
+
@include govuk-font(19, bold);
|
3
|
+
|
4
|
+
list-style-type: none;
|
5
|
+
margin-bottom: govuk-spacing(6);
|
6
|
+
margin-top: 0;
|
7
|
+
padding-left: 0;
|
8
|
+
position: relative;
|
9
|
+
|
10
|
+
.govuk-form-group {
|
11
|
+
margin-bottom: 0;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
.gem-c-reorderable-list__item {
|
16
|
+
margin-bottom: govuk-spacing(3);
|
17
|
+
border: 1px solid $govuk-border-colour;
|
18
|
+
padding: govuk-spacing(3);
|
19
|
+
}
|
20
|
+
|
21
|
+
.gem-c-reorderable-list__item--chosen {
|
22
|
+
background-color: govuk-colour('light-grey');
|
23
|
+
outline: 2px dotted $govuk-border-colour;
|
24
|
+
}
|
25
|
+
|
26
|
+
.gem-c-reorderable-list__item--drag {
|
27
|
+
background-color: govuk-colour('white');
|
28
|
+
list-style-type: none;
|
29
|
+
|
30
|
+
.gem-c-reorderable-list__actions {
|
31
|
+
visibility: hidden;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
.gem-c-reorderable-list__wrapper {
|
36
|
+
display: block;
|
37
|
+
|
38
|
+
@include govuk-media-query($from: desktop) {
|
39
|
+
display: inline-flex;
|
40
|
+
width: 100%;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
.gem-c-reorderable-list__content {
|
45
|
+
margin-bottom: govuk-spacing(2);
|
46
|
+
@include govuk-media-query($from: desktop) {
|
47
|
+
margin-bottom: 0;
|
48
|
+
flex: 0 1 auto;
|
49
|
+
min-width: 65%;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
.gem-c-reorderable-list__title {
|
54
|
+
margin: 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
.gem-c-reorderable-list__description {
|
58
|
+
@include govuk-font(16, regular);
|
59
|
+
margin: 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
.gem-c-reorderable-list__actions {
|
63
|
+
display: block;
|
64
|
+
|
65
|
+
@include govuk-media-query($from: desktop) {
|
66
|
+
flex: 1 0 auto;
|
67
|
+
text-align: right;
|
68
|
+
}
|
69
|
+
|
70
|
+
.gem-c-button {
|
71
|
+
display: none;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
.js-enabled {
|
76
|
+
.gem-c-reorderable-list__item {
|
77
|
+
@include govuk-media-query($from: desktop) {
|
78
|
+
cursor: move;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
.gem-c-reorderable-list__actions .govuk-form-group {
|
83
|
+
display: none;
|
84
|
+
}
|
85
|
+
|
86
|
+
.gem-c-reorderable-list__actions .gem-c-button {
|
87
|
+
display: inline-block;
|
88
|
+
margin-left: govuk-spacing(3);
|
89
|
+
width: 80px;
|
90
|
+
}
|
91
|
+
|
92
|
+
.gem-c-reorderable-list__actions .gem-c-button:first-of-type {
|
93
|
+
margin-left: 0;
|
94
|
+
|
95
|
+
@include govuk-media-query($from: desktop) {
|
96
|
+
margin-left: govuk-spacing(3);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
.gem-c-reorderable-list__item:first-child .gem-c-button:first-of-type,
|
101
|
+
.gem-c-reorderable-list__item:last-child .gem-c-button:last-of-type {
|
102
|
+
display: none;
|
103
|
+
|
104
|
+
@include govuk-media-query($from: desktop) {
|
105
|
+
display: inline-block;
|
106
|
+
visibility: hidden;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
.gem-c-reorderable-list__item:first-child .gem-c-button:last-of-type {
|
111
|
+
margin-left: 0;
|
112
|
+
|
113
|
+
@include govuk-media-query($from: desktop) {
|
114
|
+
margin-left: govuk-spacing(3);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%
|
2
|
-
|
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
|
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><%=
|
23
|
+
<li><%= raw(item) %></li>
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
26
26
|
<% 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
|
-
|
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 ==
|
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(
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
43
|
+
<button class="gem-c-search__submit" type="submit">
|
44
|
+
<%= button_text %>
|
45
|
+
</button>
|
35
46
|
</div>
|
36
47
|
</div>
|
37
48
|
</div>
|
@@ -15,32 +15,51 @@
|
|
15
15
|
<%= tag.div class: "gem-c-summary-list #{"govuk-summary-list--no-border" if borderless}", id: id do %>
|
16
16
|
<% if title %>
|
17
17
|
<%= content_tag(shared_helper.get_heading_level, title, class: "govuk-heading-#{heading_size} gem-c-summary-list__group-title") %>
|
18
|
-
|
18
|
+
|
19
|
+
<% if edit.any? %>
|
20
|
+
<% edit_main_link = capture do %>
|
21
|
+
<% edit_section_link_text = edit[:link_text] || t("components.summary_list.edit") %>
|
22
|
+
<%= link_to edit.fetch(:href),
|
23
|
+
class: "govuk-link",
|
24
|
+
title: "#{edit_section_link_text} #{title}",
|
25
|
+
data: edit.fetch(:data_attributes, {}) do %>
|
26
|
+
<%= edit_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" -%>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
<% if delete.any? %>
|
32
|
+
<% delete_main_link = capture do %>
|
33
|
+
<% delete_section_link_text = delete[:link_text] || t("components.summary_list.delete") %>
|
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 %>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
42
|
+
|
43
|
+
<% if edit_main_link && delete_main_link %>
|
19
44
|
<%= tag.ul class: "govuk-summary-list__actions-list gem-c-summary-list__group-actions-list" do %>
|
20
45
|
<%- if edit.any? %>
|
21
|
-
<% edit_section_link_text = edit[:link_text] || t("components.summary_list.edit") %>
|
22
46
|
<%= tag.li class: "govuk-summary-list__actions-list-item" do -%>
|
23
|
-
<%=
|
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 %>
|
47
|
+
<%= edit_main_link %>
|
29
48
|
<% end %>
|
30
49
|
<% end %>
|
31
50
|
<% if delete.any? %>
|
32
|
-
<% delete_section_link_text = delete[:link_text] || t("components.summary_list.delete") %>
|
33
51
|
<%= tag.li class: "govuk-summary-list__actions-list-item" do -%>
|
34
|
-
<%=
|
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 %>
|
52
|
+
<%= delete_main_link %>
|
40
53
|
<% end %>
|
41
54
|
<% end %>
|
42
55
|
<% end %>
|
56
|
+
<% else %>
|
57
|
+
<%= tag.div class: "govuk-summary-list__actions-list gem-c-summary-list__group-actions-list" do %>
|
58
|
+
<%= edit_main_link %>
|
59
|
+
<%= delete_main_link %>
|
60
|
+
<% end %>
|
43
61
|
<% end %>
|
62
|
+
|
44
63
|
<% end %>
|
45
64
|
|
46
65
|
<% if items.any? %>
|
@@ -51,34 +70,52 @@
|
|
51
70
|
<%= tag.dt item[:field], class: "govuk-summary-list__key" %>
|
52
71
|
<%= tag.dd item[:value], class: "govuk-summary-list__value" %>
|
53
72
|
|
54
|
-
<% if item.fetch(:edit, {}).any?
|
73
|
+
<% if item.fetch(:edit, {}).any? %>
|
74
|
+
<% edit_link = capture do %>
|
75
|
+
<% edit_link_text = item[:edit][:link_text] || t("components.summary_list.edit") %>
|
76
|
+
<%= link_to item[:edit].fetch(:href),
|
77
|
+
class: "govuk-link",
|
78
|
+
title: "#{edit_link_text} #{item[:field]}",
|
79
|
+
data: item[:edit].fetch(:data_attributes, {}) do %>
|
80
|
+
<%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" -%>
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
83
|
+
<% end %>
|
84
|
+
|
85
|
+
<% if item.fetch(:delete, {}).any? %>
|
86
|
+
<% delete_link = capture do %>
|
87
|
+
<% delete_link_text = item[:delete][:link_text] || t("components.summary_list.delete") %>
|
88
|
+
<%= link_to item[:delete].fetch(:href),
|
89
|
+
class: "govuk-link gem-link--destructive",
|
90
|
+
title: "#{delete_link_text} #{item[:field]}",
|
91
|
+
data: item[:delete].fetch(:data_attributes, {}) do %>
|
92
|
+
<%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" -%>
|
93
|
+
<% end %>
|
94
|
+
<% end %>
|
95
|
+
<% end %>
|
96
|
+
|
97
|
+
<% if edit_link && delete_link %>
|
55
98
|
<%= tag.dd class: "govuk-summary-list__actions" do %>
|
56
99
|
<%= tag.ul class: "govuk-summary-list__actions-list" do %>
|
57
100
|
<% if item.fetch(:edit, {}).any? %>
|
58
101
|
<%= tag.li class: "govuk-summary-list__actions-list-item" do %>
|
59
|
-
|
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 %>
|
102
|
+
<%= edit_link %>
|
66
103
|
<% end %>
|
67
104
|
<% end %>
|
68
105
|
<% if item.fetch(:delete, {}).any? %>
|
69
106
|
<%= tag.li class: "govuk-summary-list__actions-list-item" do %>
|
70
|
-
|
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 %>
|
107
|
+
<%= delete_link %>
|
77
108
|
<% end %>
|
78
109
|
<% end %>
|
79
110
|
<% end %>
|
80
111
|
<% end %>
|
112
|
+
<% else %>
|
113
|
+
<%= tag.dd class: "govuk-summary-list__actions" do %>
|
114
|
+
<%= edit_link %>
|
115
|
+
<%= delete_link %>
|
116
|
+
<% end %>
|
81
117
|
<% end %>
|
118
|
+
|
82
119
|
<% end %>
|
83
120
|
<% end %>
|
84
121
|
<% end %>
|