govuk_design_system_formbuilder 5.3.3 → 5.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: 49872073d9196fcaf016da8e8bb5b732cb44c4f93942ab929ea18aff46108547
4
- data.tar.gz: a1620cf4f0462a5ef72d74f10e3bab677374d7ff99a3b3c885e11bc5919a091d
3
+ metadata.gz: 2bdbbb82d892d6d8464530b6abb483d600e091ea0ab4bc62903a0bb968d3a378
4
+ data.tar.gz: 044ee86049f6e18585acc199bc03c6b77f6154681d3039fb8e6de861c8d64505
5
5
  SHA512:
6
- metadata.gz: 3067ff3c0f078d9c605abb7ce902bab9ac27da088c3b7618818d0162bcf25685716fbd66499e2c6a081344d0aebd906bbf077bfe351fc55eab58000c19a5bf4d
7
- data.tar.gz: 25e79221ae4bc57c38c9fffd3f6725ec98b5f6c2c724d05d09f954f6f9c8f52af1327e76748979774d6976974ad6418a0ec64f2e2d319eac44a580265ef0816b
6
+ metadata.gz: c74450c385e022631081c1619db5593c0a8266389cc6b026ab36a8009975281bf2723484dd85606a9b8891e75ed88504e5182edf8953bb67e9def2b99d66ac83
7
+ data.tar.gz: '0081c151c9b283d88b38b48fee760d1cbfe335dd95ae6994a1f9b744c235f31c6283ca5695f60a07e63e507849c4111a21e4baef5df5a3194569d02891f1d27d'
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Gem](https://img.shields.io/gem/dt/govuk_design_system_formbuilder?logo=rubygems)](https://rubygems.org/gems/govuk_design_system_formbuilder)
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/110136fb22341d3ba646/test_coverage)](https://codeclimate.com/github/x-govuk/govuk-form-builder/test_coverage)
8
8
  [![GitHub license](https://img.shields.io/github/license/x-govuk/govuk-form-builder)](https://github.com/x-govuk/govuk-form-builder/blob/main/LICENSE)
9
- [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-5.3.1-brightgreen)](https://design-system.service.gov.uk)
9
+ [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-5.4.0-brightgreen)](https://design-system.service.gov.uk)
10
10
  [![Rails](https://img.shields.io/badge/Rails-6.1.7%20%E2%95%B1%207.1.3-E16D6D)](https://weblog.rubyonrails.org/releases/)
11
11
  [![Ruby](https://img.shields.io/badge/Ruby-3.1.4%20%20%E2%95%B1%203.2.3%20%20%E2%95%B1%203.3.0-E16D6D)](https://www.ruby-lang.org/en/downloads/)
12
12
 
@@ -118,8 +118,8 @@ Approximately [100 services use this library](https://github.com/x-govuk/govuk-f
118
118
  here are a few from the <abbr title="Department for Education">DfE</abbr>, <abbr title="Ministry of Justice">MoJ</abbr>, and
119
119
  <abbr title="Department for Business, Energy & Industrial Strategy">BEIS</abbr>.
120
120
 
121
- * [Apply for teacher training](https://www.github.com/x-govuk/apply-for-teacher-training)
122
- * [Teaching Vacancies](https://www.github.com/x-govuk/teaching-vacancies)
121
+ * [Apply for teacher training](https://www.github.com/dfe-digital/apply-for-teacher-training)
122
+ * [Teaching Vacancies](https://www.github.com/dfe-digital/teaching-vacancies)
123
123
  * [Manage children's vaccinations](https://github.com/nhsuk/manage-childrens-vaccinations)
124
124
  * [Claim for crown court defence](https://www.github.com/ministryofjustice/Claim-for-Crown-Court-Defence)
125
125
  * [Appeal to the tax tribunal](https://www.github.com/ministryofjustice/tax-tribunals-datacapture)
@@ -922,6 +922,8 @@ module GOVUKDesignSystemFormBuilder
922
922
  # @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
923
923
  # @param omit_day [Boolean] do not render a day input, only capture month and year
924
924
  # @param maxlength_enabled [Boolean] adds maxlength attribute to day, month and year inputs (2, 2, and 4, respectively)
925
+ # @param segments [Hash] allows Rails' multiparameter attributes to be overridden on a field-by-field basis. Hash must
926
+ # contain +day:+, +month:+ and +year:+ keys. Defaults to the default value set in the +default_date_segments+ setting in {GOVUKDesignSystemFormBuilder.DEFAULTS}
925
927
  # @param form_group [Hash] configures the form group
926
928
  # @option form_group kwargs [Hash] additional attributes added to the form group
927
929
  # @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element
@@ -944,8 +946,8 @@ module GOVUKDesignSystemFormBuilder
944
946
  # @example A date input with legend supplied as a proc
945
947
  # = f.govuk_date_field :finishes_on,
946
948
  # legend: -> { tag.h3('Which category do you belong to?') }
947
- def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, form_group: {}, **kwargs, &block)
948
- Elements::Date.new(self, object_name, attribute_name, hint:, legend:, caption:, date_of_birth:, omit_day:, maxlength_enabled:, form_group:, **kwargs, &block).html
949
+ def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, maxlength_enabled: false, segments: config.default_date_segments, form_group: {}, **kwargs, &block)
950
+ Elements::Date.new(self, object_name, attribute_name, hint:, legend:, caption:, date_of_birth:, omit_day:, maxlength_enabled:, segments:, form_group:, **kwargs, &block).html
949
951
  end
950
952
 
951
953
  # Generates a summary of errors in the form, each linking to the corresponding
@@ -10,7 +10,7 @@ module GOVUKDesignSystemFormBuilder
10
10
 
11
11
  MULTIPARAMETER_KEY = { day: 3, month: 2, year: 1 }.freeze
12
12
 
13
- def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, form_group:, date_of_birth: false, **kwargs, &block)
13
+ def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, segments:, form_group:, date_of_birth: false, **kwargs, &block)
14
14
  super(builder, object_name, attribute_name, &block)
15
15
 
16
16
  @legend = legend
@@ -19,6 +19,7 @@ module GOVUKDesignSystemFormBuilder
19
19
  @date_of_birth = date_of_birth
20
20
  @omit_day = omit_day
21
21
  @maxlength_enabled = maxlength_enabled
22
+ @segments = segments
22
23
  @form_group = form_group
23
24
  @html_attributes = kwargs
24
25
  end
@@ -33,10 +34,6 @@ module GOVUKDesignSystemFormBuilder
33
34
 
34
35
  private
35
36
 
36
- def segments
37
- config.default_date_segments
38
- end
39
-
40
37
  def fieldset_options
41
38
  { legend: @legend, caption: @caption, described_by: [error_id, hint_id, supplemental_id] }
42
39
  end
@@ -139,7 +136,7 @@ module GOVUKDesignSystemFormBuilder
139
136
  if has_errors? && link_errors
140
137
  field_id(link_errors:)
141
138
  else
142
- [@object_name, @attribute_name, segments.fetch(segment)].join("_")
139
+ [@object_name, @attribute_name, @segments.fetch(segment)].join("_")
143
140
  end
144
141
  end
145
142
 
@@ -148,7 +145,7 @@ module GOVUKDesignSystemFormBuilder
148
145
  "%<object_name>s[%<input_name>s(%<segment>s)]",
149
146
  object_name: @object_name,
150
147
  input_name: @attribute_name,
151
- segment: segments.fetch(segment)
148
+ segment: @segments.fetch(segment)
152
149
  )
153
150
  end
154
151
 
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '5.3.3'.freeze
2
+ VERSION = '5.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: 5.3.3
4
+ version: 5.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: 2024-04-23 00:00:00.000000000 Z
11
+ date: 2024-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-attributes-utils
@@ -260,14 +260,14 @@ dependencies:
260
260
  requirements:
261
261
  - - "~>"
262
262
  - !ruby/object:Gem::Version
263
- version: 0.26.0
263
+ version: 0.27.0
264
264
  type: :development
265
265
  prerelease: false
266
266
  version_requirements: !ruby/object:Gem::Requirement
267
267
  requirements:
268
268
  - - "~>"
269
269
  - !ruby/object:Gem::Version
270
- version: 0.26.0
270
+ version: 0.27.0
271
271
  - !ruby/object:Gem::Dependency
272
272
  name: webrick
273
273
  requirement: !ruby/object:Gem::Requirement