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: 2f56b92f232ffd2b98c38637c49b2e4255f3be12cab3825f795a735cbfae0107
4
- data.tar.gz: 0f4dfd572130559b3140a838310ce471a4adee41f46fed32ca5046cfa29ed9d0
3
+ metadata.gz: 56faf8610c088256377104bf569648d400a885f14ac4473004f6e274e369bcf0
4
+ data.tar.gz: d33bc39a755f8241b61dc94bef11b51734786e781a0f2e046b27438996161aa2
5
5
  SHA512:
6
- metadata.gz: 67861fee01f6a14cac7bbf9db87d1633dcf13e569aaa2179f5e16d21f8aed5e7b7d553a5bd96e601ab5b4181e6c27c905fa5fd6d7e80c811a2cff28d42b1f83f
7
- data.tar.gz: a889d6d02fd1978e73aa2328debc5b6268993eca88755b3cf31889dfe4c973d28e09dfb9d13bbe462347aeea74a1f46dfb8ba8f4f7c20ad3da5c2c8d1d6aa114
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,
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '2.3.0'.freeze
2
+ VERSION = '2.4.0'.freeze
3
3
  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: 2.3.0
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-03-30 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge