govuk_admin_template 4.3.0 → 4.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
  SHA1:
3
- metadata.gz: da51806c92ecf192e1e86588976fdfff18ba48f8
4
- data.tar.gz: 9f7cfd6b015eda2f45d667af4e4a3c880a80dc28
3
+ metadata.gz: 2c56ebc64084872a0154fa55966b9a1d03693533
4
+ data.tar.gz: 10700fabdcf062fe7cb012fc503dab55eea24897
5
5
  SHA512:
6
- metadata.gz: 1488d3bf3e4058e4d38d233e407640e919a5954095d5bc3dd98a4aa1b00ee546ac3f1257f303e8dae720d27a8212fe9da4fe2bcfcf58da32ac2867aee774867a
7
- data.tar.gz: 8407e2e16bbe1702dc33d5c324eabfca39b6ec26233122a023fed63e5e79bf3b9b29530b79bddc7c0752375b4c424d653447480bf41e5abe1aa62dfae868f774
6
+ metadata.gz: 778b339983aa3c70e7e695f2fe7ec7d3420b59ce89f32e6ade5b6cb2488e91c7e1245dfe50a70815ae6a45362f6f350e3faa669c45fb64c67b73f7b46e89ab63
7
+ data.tar.gz: 031bff6de0929be3b955784d3bdf420df310ef6582e724ebd7070ec6fe99d51c3f406bb7568e5f0201f55bae9cc67d1983683ff1298b53c487652813bd4533c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 4.4.0
2
+
3
+ * Include optional `simple_form` configuration and locale files
4
+
1
5
  # 4.3.0
2
6
 
3
7
  * Add Rails 5 compatibility
data/README.md CHANGED
@@ -73,7 +73,7 @@ in your `spec/javascripts/support/jasmine.yml` like this:
73
73
  ```yaml
74
74
  src_files:
75
75
  - assets/govuk-admin-template.js
76
- ```
76
+ ```
77
77
 
78
78
  It is recommended that the style guide is also made available within your app at the route `/style-guide`. Add this to your `config/routes.rb` file:
79
79
 
@@ -101,6 +101,29 @@ GovukAdminTemplate.configure do |c|
101
101
  end
102
102
  ```
103
103
 
104
+ ### Forms
105
+
106
+ Some GOV.UK admin apps use the [Simple
107
+ Form](https://github.com/plataformatec/simple_form) library for writing form
108
+ markup. This repo contains a recommended configuration in
109
+ `lib/govuk_admin_template/simple_form.rb`.
110
+
111
+ To use this configuration:
112
+
113
+ 0. Add `simple_form` to your Gemfile.
114
+ 0. Add an initializer in `config/initializers/simple_form.rb` containing the
115
+ following:
116
+
117
+ ```
118
+ SimpleForm.setup do |config|
119
+ GovukAdminTemplate.setup_simple_form(config)
120
+ end
121
+ ```
122
+
123
+ This gem also provides an i18n file in `config/locales/simple_form.en.yml`.
124
+ This removes the need for this file to be present in the host project unless
125
+ specific customisations are required.
126
+
104
127
  ### Content blocks
105
128
 
106
129
  The gem [uses nested layouts](http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts) for customisation.
@@ -0,0 +1,31 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Examples
14
+ labels:
15
+ defaults:
16
+ title: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
@@ -2,6 +2,7 @@ require "govuk_admin_template/version"
2
2
  require "govuk_admin_template/engine"
3
3
  require "govuk_admin_template/config"
4
4
  require "govuk_admin_template/view_helpers"
5
+ require "govuk_admin_template/simple_form"
5
6
 
6
7
  module GovukAdminTemplate
7
8
  mattr_accessor :environment_style, :environment_label
@@ -0,0 +1,100 @@
1
+ module GovukAdminTemplate
2
+ def self.setup_simple_form(config)
3
+ # Wrappers are used by the form builder to generate a complete input.
4
+ # You can remove any component from the wrapper, change the order or
5
+ # even add your own to the stack.
6
+
7
+ # The options given below are used to wrap the whole input.
8
+ config.wrappers :default, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b|
9
+ # Determines whether to use HTML5 (:email, :url, ...)
10
+ # and required attributes
11
+ b.use :html5
12
+
13
+ # Calculates placeholders automatically from I18n
14
+ # You can also pass a string as f.input placeholder: "Placeholder"
15
+ b.use :placeholder
16
+
17
+ ## Optional extensions
18
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
19
+ # to the input. If so, they will retrieve the values from the model
20
+ # if any exists. If you want to enable the lookup for any of those
21
+ # extensions by default, you can change `b.optional` to `b.use`.
22
+
23
+ # Calculates maxlength from length validations for string inputs
24
+ b.optional :maxlength
25
+
26
+ # Calculates pattern from format validations for string inputs
27
+ b.optional :pattern
28
+
29
+ # Calculates min and max from length validations for numeric inputs
30
+ b.optional :min_max
31
+
32
+ # Calculates readonly automatically from readonly attributes
33
+ b.optional :readonly
34
+
35
+ ## Inputs
36
+ b.use :label_input
37
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
38
+ b.use :error, wrap_with: { tag: :span, class: :error }
39
+ end
40
+
41
+ config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
42
+ b.use :html5
43
+ b.use :placeholder
44
+ b.use :label, class: 'control-label'
45
+ b.wrapper tag: 'div' do |ba|
46
+ ba.use :input
47
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
48
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
49
+ end
50
+ end
51
+
52
+ config.wrappers :prepend, tag: 'div', class: "form-group", error_class: 'has-error' do |b|
53
+ b.use :html5
54
+ b.use :placeholder
55
+ b.use :label
56
+ b.wrapper tag: 'div', class: 'controls' do |input|
57
+ input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
58
+ prepend.use :input
59
+ end
60
+ input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
61
+ input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
62
+ end
63
+ end
64
+
65
+ config.wrappers :append, tag: 'div', class: "form-group", error_class: 'has-error' do |b|
66
+ b.use :html5
67
+ b.use :placeholder
68
+ b.use :label
69
+ b.wrapper tag: 'div', class: 'controls' do |input|
70
+ input.wrapper tag: 'div', class: 'input-append' do |append|
71
+ append.use :input
72
+ end
73
+ input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
74
+ input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
75
+ end
76
+ end
77
+
78
+ # The default wrapper to be used by the FormBuilder.
79
+ config.default_wrapper = :bootstrap
80
+
81
+ # Define the way to render check boxes / radio buttons with labels.
82
+ # Defaults to :nested for bootstrap config.
83
+ # inline: input + label
84
+ # nested: label > input
85
+ config.boolean_style = :inline
86
+
87
+ # Default class for buttons
88
+ config.button_class = 'btn'
89
+
90
+ # Default tag used for error notification helper.
91
+ config.error_notification_tag = :div
92
+
93
+ # CSS class to add for error notification helper.
94
+ config.error_notification_class = 'alert alert-danger'
95
+
96
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
97
+ # Default is enabled.
98
+ config.browser_validations = false
99
+ end
100
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukAdminTemplate
2
- VERSION = "4.3.0"
2
+ VERSION = "4.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_admin_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -175,10 +175,12 @@ files:
175
175
  - app/views/govuk_admin_template/_table_filter.html.erb
176
176
  - app/views/govuk_admin_template/style_guide/index.html.erb
177
177
  - app/views/layouts/govuk_admin_template.html.erb
178
+ - config/locales/simple_form.en.yml
178
179
  - config/routes.rb
179
180
  - lib/govuk_admin_template.rb
180
181
  - lib/govuk_admin_template/config.rb
181
182
  - lib/govuk_admin_template/engine.rb
183
+ - lib/govuk_admin_template/simple_form.rb
182
184
  - lib/govuk_admin_template/version.rb
183
185
  - lib/govuk_admin_template/view_helpers.rb
184
186
  homepage: https://github.com/alphagov/govuk_admin_template