govuk_design_system_formbuilder 2.1.4 → 2.1.5
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: f2892780c7524701d967f5ed6c409ad4eb741b5a3e6cfaf4ec65389dbaf504a4
|
4
|
+
data.tar.gz: 5a231ba3dfebdf493b8563fc2d7c4b11ba66d27963512e24ef6cd9647ba8bee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46966873483f3cec59d97458b1e211ab013d7056c6d18e6bd40749f393e6e5eff96e93ddf38d6888da4316cd26db7d3a6dbd9e744e40d3fa6b2b4ac5386281b8
|
7
|
+
data.tar.gz: cff65a82d937855335ef59346acb8d4e2a07e21ca615897c8dd9b0c873e2e919a794ac46dcfdde27054211f573c7be030d1b64a8b5fd1fa325f34ae1ecd8811d
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# GOV.UK Design System Form Builder for Rails
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Tests](https://github.com/DFE-Digital/govuk_design_system_formbuilder/workflows/Testing/badge.svg)](https://github.com/DFE-Digital/govuk_design_system_formbuilder/actions)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/fde73b5dc9476197281b/maintainability)](https://codeclimate.com/github/DFE-Digital/govuk_design_system_formbuilder/maintainability)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/govuk_design_system_formbuilder.svg)](https://badge.fury.io/rb/govuk_design_system_formbuilder)
|
6
6
|
[![Gem](https://img.shields.io/gem/dt/govuk_design_system_formbuilder?logo=rubygems)](https://rubygems.org/gems/govuk_design_system_formbuilder)
|
@@ -850,6 +850,7 @@ module GOVUKDesignSystemFormBuilder
|
|
850
850
|
# @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
|
851
851
|
# @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
|
852
852
|
# @param omit_day [Boolean] do not render a day input, only capture month and year
|
853
|
+
# @param wildcards [Boolean] add an 'X' to the date wildcards so users can add approximate dates
|
853
854
|
# @param form_group [Hash] configures the form group
|
854
855
|
# @option form_group classes [Array,String] sets the form group's classes
|
855
856
|
# @option form_group kwargs [Hash] additional attributes added to the form group
|
@@ -872,8 +873,8 @@ module GOVUKDesignSystemFormBuilder
|
|
872
873
|
# @example A date input with legend supplied as a proc
|
873
874
|
# = f.govuk_date_field :finishes_on,
|
874
875
|
# legend: -> { tag.h3('Which category do you belong to?') }
|
875
|
-
def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, form_group: {}, &block)
|
876
|
-
Elements::Date.new(self, object_name, attribute_name, hint: hint, legend: legend, caption: caption, date_of_birth: date_of_birth, omit_day: omit_day, form_group: form_group, &block).html
|
876
|
+
def govuk_date_field(attribute_name, hint: {}, legend: {}, caption: {}, date_of_birth: false, omit_day: false, form_group: {}, wildcards: false, &block)
|
877
|
+
Elements::Date.new(self, object_name, attribute_name, hint: hint, legend: legend, caption: caption, date_of_birth: date_of_birth, omit_day: omit_day, form_group: form_group, wildcards: wildcards, &block).html
|
877
878
|
end
|
878
879
|
|
879
880
|
# Generates a summary of errors in the form, each linking to the corresponding
|
@@ -9,7 +9,7 @@ module GOVUKDesignSystemFormBuilder
|
|
9
9
|
|
10
10
|
SEGMENTS = { day: '3i', month: '2i', year: '1i' }.freeze
|
11
11
|
|
12
|
-
def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, date_of_birth: false, omit_day:, form_group:, &block)
|
12
|
+
def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, date_of_birth: false, omit_day:, form_group:, wildcards:, &block)
|
13
13
|
super(builder, object_name, attribute_name, &block)
|
14
14
|
|
15
15
|
@legend = legend
|
@@ -18,6 +18,7 @@ module GOVUKDesignSystemFormBuilder
|
|
18
18
|
@date_of_birth = date_of_birth
|
19
19
|
@omit_day = omit_day
|
20
20
|
@form_group = form_group
|
21
|
+
@wildcards = wildcards
|
21
22
|
end
|
22
23
|
|
23
24
|
def html
|
@@ -82,13 +83,19 @@ module GOVUKDesignSystemFormBuilder
|
|
82
83
|
class: classes(width),
|
83
84
|
name: name(segment),
|
84
85
|
type: 'text',
|
85
|
-
pattern:
|
86
|
+
pattern: pattern(segment),
|
86
87
|
inputmode: 'numeric',
|
87
88
|
value: value,
|
88
89
|
autocomplete: date_of_birth_autocomplete_value(segment)
|
89
90
|
)
|
90
91
|
end
|
91
92
|
|
93
|
+
def pattern(segment)
|
94
|
+
return '[0-9X]*' if @wildcards && segment.in?(%i(day month))
|
95
|
+
|
96
|
+
'[0-9]*'
|
97
|
+
end
|
98
|
+
|
92
99
|
def classes(width)
|
93
100
|
%w(input date-input__input).prefix(brand).tap do |classes|
|
94
101
|
classes.push(%(#{brand}-input--width-#{width}))
|
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.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|