govuk_design_system_formbuilder 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56faf8610c088256377104bf569648d400a885f14ac4473004f6e274e369bcf0
|
4
|
+
data.tar.gz: d33bc39a755f8241b61dc94bef11b51734786e781a0f2e046b27438996161aa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb539b28abcd66fedd8bfb67ae7341e3394503eea648c5fd7c88a453163cac93b31ff5c21d91971f36348bb2f194becc5346382f995d464c148865a6c17ab57c
|
7
|
+
data.tar.gz: 4dc4ad392b0889678d009e4b0c4e502c8dad962b9a6ded83b079e319efd0e7760c78151bfe964d3d825328eef9760324a124ea7800593f2be0e454f5836722d5
|
@@ -842,6 +842,7 @@ module GOVUKDesignSystemFormBuilder
|
|
842
842
|
# @note When using this input be aware that Rails's multiparam time and date handling falls foul
|
843
843
|
# of {https://bugs.ruby-lang.org/issues/5988 this} bug, so incorrect dates like +2019-09-31+ will
|
844
844
|
# be 'rounded' up to +2019-10-01+.
|
845
|
+
# @note When using this input values will be retrieved from the attribute if it is a Date object or a multiparam date hash
|
845
846
|
# @param attribute_name [Symbol] The name of the attribute
|
846
847
|
# @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
|
847
848
|
# supplied the hint will be wrapped in a +div+ instead of a +span+
|
@@ -8,6 +8,7 @@ module GOVUKDesignSystemFormBuilder
|
|
8
8
|
include Traits::Supplemental
|
9
9
|
|
10
10
|
SEGMENTS = { day: '3i', month: '2i', year: '1i' }.freeze
|
11
|
+
MULTIPARAMETER_KEY = { day: 3, month: 2, year: 1 }.freeze
|
11
12
|
|
12
13
|
def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, form_group:, wildcards:, date_of_birth: false, **kwargs, &block)
|
13
14
|
super(builder, object_name, attribute_name, &block)
|
@@ -61,15 +62,19 @@ module GOVUKDesignSystemFormBuilder
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def date_part(segment, width:, link_errors: false)
|
64
|
-
value = @builder.object.try(@attribute_name).try(segment)
|
65
|
-
|
66
65
|
tag.div(class: %(#{brand}-date-input__item)) do
|
67
66
|
tag.div(class: %(#{brand}-form-group)) do
|
68
|
-
safe_join([label(segment, link_errors), input(segment, link_errors, width, value)])
|
67
|
+
safe_join([label(segment, link_errors), input(segment, link_errors, width, value(segment))])
|
69
68
|
end
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
72
|
+
def value(segment)
|
73
|
+
attribute = @builder.object.try(@attribute_name)
|
74
|
+
|
75
|
+
attribute.try(segment) || attribute.try(:[], MULTIPARAMETER_KEY[segment])
|
76
|
+
end
|
77
|
+
|
73
78
|
def label(segment, link_errors)
|
74
79
|
tag.label(
|
75
80
|
segment.capitalize,
|
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.4.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-
|
11
|
+
date: 2021-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|