govuk_design_system_formbuilder 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/govuk_design_system_formbuilder/builder.rb +5 -4
- data/lib/govuk_design_system_formbuilder/elements/error_summary.rb +4 -2
- data/lib/govuk_design_system_formbuilder/elements/submit.rb +14 -2
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08308443752eddad69642235b4098b788ed5c5eb701b6f97d344171b9654a135'
|
4
|
+
data.tar.gz: 0f3b209aee144ea52d46798b14a29ea1a85b9acf545413d0219efeff03b92e8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 425224ce7905d2dd33d2123698c6f35f68e2ac640743326f811ab7b45241134f640bc054b7b75a3813edd2be558b794119437d8d4917adbe03f5cc42e38a74b9
|
7
|
+
data.tar.gz: 22d147336200ed390422201ece082289db29d6ee637aad76157195c9401fbbe52cfe6c9c9a80cd357f41543d133009a248a207547b0debaae46503503d26fe93
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
[![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk_design_system_formbuilder)](https://github.com/DFE-Digital/govuk_design_system_formbuilder/blob/master/LICENSE)
|
10
10
|
[![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.12.0-brightgreen)](https://design-system.service.gov.uk)
|
11
11
|
[![Rails](https://img.shields.io/badge/Ruby-2.6.7%20%E2%95%B1%202.7.3%20%E2%95%B1%203.0.1-E16D6D)](https://www.ruby-lang.org/en/downloads/)
|
12
|
-
[![Ruby](https://img.shields.io/badge/Rails-6.0.
|
12
|
+
[![Ruby](https://img.shields.io/badge/Rails-6.0.4%20%E2%95%B1%206.1.3.2-E16D6D)](https://weblog.rubyonrails.org/releases/)
|
13
13
|
|
14
14
|
This library provides an easy-to-use form builder for the [GOV.UK Design System](https://design-system.service.gov.uk/).
|
15
15
|
|
@@ -843,7 +843,7 @@ module GOVUKDesignSystemFormBuilder
|
|
843
843
|
|
844
844
|
# Generates a submit button, green by default
|
845
845
|
#
|
846
|
-
# @param text [String] the button text
|
846
|
+
# @param text [String,Proc] the button text. When a +Proc+ is provided its contents will be rendered within the button element
|
847
847
|
# @param warning [Boolean] makes the button red ({https://design-system.service.gov.uk/components/button/#warning-buttons warning}) when true
|
848
848
|
# @param secondary [Boolean] makes the button grey ({https://design-system.service.gov.uk/components/button/#secondary-buttons secondary}) when true
|
849
849
|
# @param classes [Array,String] Classes to add to the submit button
|
@@ -853,7 +853,7 @@ module GOVUKDesignSystemFormBuilder
|
|
853
853
|
# client-side validation provided by the browser. This is to provide a more consistent and accessible user
|
854
854
|
# experience
|
855
855
|
# @param disabled [Boolean] makes the button disabled when true
|
856
|
-
# @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +
|
856
|
+
# @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +button+ element
|
857
857
|
# @param block [Block] When content is passed in via a block the submit element and the block content will
|
858
858
|
# be wrapped in a +<div class="govuk-button-group">+ which will space the buttons and links within
|
859
859
|
# evenly.
|
@@ -861,8 +861,9 @@ module GOVUKDesignSystemFormBuilder
|
|
861
861
|
# @return [ActiveSupport::SafeBuffer] HTML output
|
862
862
|
# @note Only the first additional button or link (passed in via a block) will be given the
|
863
863
|
# correct left margin, subsequent buttons will need to be manually accounted for
|
864
|
-
# @note This helper always renders an +<
|
865
|
-
#
|
864
|
+
# @note This helper always renders an +<button type='submit'>+ tag. Previous versions of this gem rendered
|
865
|
+
# a +`<input type='submit'>' tag instead, but there is a {https://github.com/alphagov/govuk_elements/issues/545 longstanding bug}
|
866
|
+
# with this approach where the top few pixels don't initiate a submission when clicked.
|
866
867
|
# @see https://design-system.service.gov.uk/components/button/#stop-users-from-accidentally-sending-information-more-than-once
|
867
868
|
# GOV.UK double click prevention
|
868
869
|
#
|
@@ -41,8 +41,10 @@ module GOVUKDesignSystemFormBuilder
|
|
41
41
|
messages = @builder.object.errors.messages
|
42
42
|
|
43
43
|
if reorder_errors?
|
44
|
-
|
45
|
-
|
44
|
+
adjustment = error_order.size + messages.size
|
45
|
+
|
46
|
+
return messages.sort_by.with_index do |(attr, _val), i|
|
47
|
+
error_order.index(attr) || (i + adjustment)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -9,7 +9,7 @@ module GOVUKDesignSystemFormBuilder
|
|
9
9
|
|
10
10
|
fail ArgumentError, 'buttons can be warning or secondary' if warning && secondary
|
11
11
|
|
12
|
-
@text = text
|
12
|
+
@text = build_text(text)
|
13
13
|
@prevent_double_click = prevent_double_click
|
14
14
|
@warning = warning
|
15
15
|
@secondary = secondary
|
@@ -26,6 +26,17 @@ module GOVUKDesignSystemFormBuilder
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
+
def build_text(text)
|
30
|
+
case text
|
31
|
+
when String
|
32
|
+
text
|
33
|
+
when Proc
|
34
|
+
capture { text.call }
|
35
|
+
else
|
36
|
+
fail(ArgumentError, %(text must be a String or Proc))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
29
40
|
def button_group
|
30
41
|
Containers::ButtonGroup.new(@builder, buttons).html
|
31
42
|
end
|
@@ -35,11 +46,12 @@ module GOVUKDesignSystemFormBuilder
|
|
35
46
|
end
|
36
47
|
|
37
48
|
def submit
|
38
|
-
@builder.
|
49
|
+
@builder.tag.button(@text, **attributes(@html_attributes))
|
39
50
|
end
|
40
51
|
|
41
52
|
def options
|
42
53
|
{
|
54
|
+
type: 'submit',
|
43
55
|
formnovalidate: !@validate,
|
44
56
|
disabled: @disabled,
|
45
57
|
class: classes,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_design_system_formbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|