govuk_design_system_formbuilder 1.1.0.beta.1 → 1.1.0.beta.2
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 +4 -4
- data/lib/govuk_design_system_formbuilder/containers/fieldset.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/hint.rb +1 -1
- data/lib/govuk_design_system_formbuilder/elements/label.rb +1 -1
- data/lib/govuk_design_system_formbuilder/traits/localisation.rb +21 -1
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- data/lib/govuk_design_system_formbuilder.rb +36 -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: 82e501f7e5b7cd7dd736262ffb97f54c0aeead0342d27d8a349d05f13839b58b
|
4
|
+
data.tar.gz: ea1da5f05bb735f6fdd4d0f12dc0baefde84b07e54dc493625407f0315c9cf3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7244ee3061ca5184f18fd12ed6b98e74eb842d465fe77becae6322728d95b7acfe4b444ce37c48df2a687129bd52b5b5d85bd1d11c3662b42408f1d1c4d7d87
|
7
|
+
data.tar.gz: 3546f3587c2df1aea3c66dc50e835a228e0735d653bf41982ff13651c2a06310431336484b1872635c7f37ba0e2206f992a343c5022e4eec12edcbfeff9529a5
|
@@ -37,7 +37,7 @@ module GOVUKDesignSystemFormBuilder
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def label_text(option_text, hidden)
|
40
|
-
text = [option_text, @value, localised_text(
|
40
|
+
text = [option_text, @value, localised_text(:label), @attribute_name.capitalize].compact.first.to_s
|
41
41
|
|
42
42
|
if hidden
|
43
43
|
tag.span(text, class: %w(govuk-visually-hidden))
|
@@ -14,7 +14,27 @@ module GOVUKDesignSystemFormBuilder
|
|
14
14
|
def localisation_key(context)
|
15
15
|
return nil unless @object_name.present? && @attribute_name.present?
|
16
16
|
|
17
|
-
|
17
|
+
schema(context)
|
18
|
+
end
|
19
|
+
|
20
|
+
def schema(context)
|
21
|
+
schema_root(context)
|
22
|
+
.push(@object_name, @attribute_name)
|
23
|
+
.map { |e| e == :__context__ ? context : e }
|
24
|
+
.join('.')
|
25
|
+
end
|
26
|
+
|
27
|
+
def schema_root(context)
|
28
|
+
contextual_schema = case context
|
29
|
+
when :legend
|
30
|
+
config.localisation_schema_legend
|
31
|
+
when :hint
|
32
|
+
config.localisation_schema_hint
|
33
|
+
when :label
|
34
|
+
config.localisation_schema_label
|
35
|
+
end
|
36
|
+
|
37
|
+
(contextual_schema || config.localisation_schema_fallback).dup
|
18
38
|
end
|
19
39
|
end
|
20
40
|
end
|
@@ -52,12 +52,47 @@ require 'govuk_design_system_formbuilder/containers/supplemental'
|
|
52
52
|
module GOVUKDesignSystemFormBuilder
|
53
53
|
include ActiveSupport::Configurable
|
54
54
|
|
55
|
+
# @!group Defaults
|
56
|
+
|
57
|
+
# Default form builder configuration
|
58
|
+
#
|
59
|
+
# * +:default_legend_size+ controls the default size of legend text.
|
60
|
+
# Can be either +xl+, +l+, +m+ or +s+.
|
61
|
+
#
|
62
|
+
# * +:default_legend_tag+ controls the default tag that legends are
|
63
|
+
# wrapped in. Defaults to +h1+.
|
64
|
+
#
|
65
|
+
# * +:default_submit_button_text+ sets the value assigned to +govuk_submit+,
|
66
|
+
# defaults to 'Continue'.
|
67
|
+
#
|
68
|
+
# * +:default_submit_button_text+ sets the text used to divide the last radio
|
69
|
+
# button in radio button fieldsets. As per the GOV.UK Design System spec,
|
70
|
+
# it defaults to 'or'.
|
71
|
+
#
|
72
|
+
# * +:default_error_summary_title+ sets the text used in error summary
|
73
|
+
# blocks. As per the GOV.UK Design System spec, it defaults to
|
74
|
+
# 'There is a problem'.
|
75
|
+
#
|
76
|
+
# * +:localisation_schema_fallback+ sets the prefix elements for the array
|
77
|
+
# used to build the localisation string. The final two elements are always
|
78
|
+
# are the object name and attribute name. The _special_ value +__context__+,
|
79
|
+
# is used as a placeholder for the context (label, fieldset or hint).
|
80
|
+
#
|
81
|
+
# * +:localisation_schema_legend+, +:localisation_schema_hint+ and
|
82
|
+
# +:localisation_schema_label+ each override the schema root for their
|
83
|
+
# particular context, allowing them to be independently customised.
|
84
|
+
# ===
|
55
85
|
DEFAULTS = {
|
56
86
|
default_legend_size: 'm',
|
57
87
|
default_legend_tag: 'h1',
|
58
88
|
default_submit_button_text: 'Continue',
|
59
89
|
default_radio_divider_text: 'or',
|
60
|
-
default_error_summary_title: 'There is a problem'
|
90
|
+
default_error_summary_title: 'There is a problem',
|
91
|
+
|
92
|
+
localisation_schema_fallback: %i(helpers __context__),
|
93
|
+
localisation_schema_label: nil,
|
94
|
+
localisation_schema_hint: nil,
|
95
|
+
localisation_schema_legend: nil
|
61
96
|
}.freeze
|
62
97
|
|
63
98
|
DEFAULTS.keys.each { |k| config_accessor(k) { DEFAULTS[k] } }
|
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.1.0.beta.
|
4
|
+
version: 1.1.0.beta.2
|
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-12-
|
11
|
+
date: 2019-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|