govuk_design_system_formbuilder 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a461a934a644c5132053494bb2f7226da713744089d2d2685c2288abb203fbc6
|
4
|
+
data.tar.gz: 6015d09960437e4f7c3672738da64bc67ff7651135e0f8ce52f4e5c261ec1e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50b788c0351f43d4919473f08cc4ba58da35a5e899fcdb1556a5ecf4edfbeb8ef327930a6a605fffee68b83d6db7cd90019ad525c86f88ce11a02eb0fd4284af
|
7
|
+
data.tar.gz: 36a30c7e31d409ef926726c0b2c56fda14c2c2606310c948810f288db2ef2a64637b9c9104d43f368e32bb5ebff4a38719a8e38a9fd76367f97e762d96b92fb7
|
@@ -68,6 +68,14 @@ module GOVUKDesignSystemFormBuilder
|
|
68
68
|
build_id('supplemental')
|
69
69
|
end
|
70
70
|
|
71
|
+
# Provides an id for use by the textual description of character and word limits.
|
72
|
+
#
|
73
|
+
# @note In order for the GOV.UK Frontend JavaScript to pick up this associated field
|
74
|
+
# it has to have the same id as the text area with the additional suffix of '-info'
|
75
|
+
def limit_id
|
76
|
+
[field_id(link_errors: true), 'info'].join('-')
|
77
|
+
end
|
78
|
+
|
71
79
|
def has_errors?
|
72
80
|
@builder.object.errors.any? &&
|
73
81
|
@builder.object.errors.messages.dig(@attribute_name).present?
|
@@ -23,14 +23,11 @@ module GOVUKDesignSystemFormBuilder
|
|
23
23
|
id: field_id(link_errors: true),
|
24
24
|
class: govuk_textarea_classes,
|
25
25
|
aria: {
|
26
|
-
describedby: described_by(
|
27
|
-
hint_id,
|
28
|
-
error_id,
|
29
|
-
supplemental_id
|
30
|
-
)
|
26
|
+
describedby: described_by(hint_id, error_id, supplemental_id, limit_description_id)
|
31
27
|
},
|
32
28
|
**@extra_args.merge(rows: @rows)
|
33
|
-
)
|
29
|
+
),
|
30
|
+
limit_description
|
34
31
|
].flatten.compact
|
35
32
|
)
|
36
33
|
end
|
@@ -49,6 +46,28 @@ module GOVUKDesignSystemFormBuilder
|
|
49
46
|
def limit?
|
50
47
|
@max_words || @max_chars
|
51
48
|
end
|
49
|
+
|
50
|
+
def limit_description
|
51
|
+
return nil unless limit?
|
52
|
+
|
53
|
+
content_tag('span', id: limit_id, class: %w(govuk-hint govuk-character-count__message), aria: { live: 'polite' }) do
|
54
|
+
"You can enter up to #{limit_quantity} #{limit_type}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def limit_quantity
|
59
|
+
@max_words || @max_chars
|
60
|
+
end
|
61
|
+
|
62
|
+
def limit_type
|
63
|
+
@max_words.present? ? 'words' : 'characters'
|
64
|
+
end
|
65
|
+
|
66
|
+
def limit_description_id
|
67
|
+
return nil unless limit?
|
68
|
+
|
69
|
+
limit_id
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|
54
73
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|