ccs-frontend_helpers 0.1.0.rc.2 → 0.1.0.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/ccs/components/ccs/dashboard_section/panel.rb +43 -41
- data/lib/ccs/components/ccs/dashboard_section.rb +50 -48
- data/lib/ccs/components/ccs/footer/link.rb +41 -39
- data/lib/ccs/components/ccs/footer/meta.rb +49 -48
- data/lib/ccs/components/ccs/footer/navigation.rb +51 -50
- data/lib/ccs/components/ccs/footer.rb +69 -67
- data/lib/ccs/components/ccs/header/link.rb +47 -45
- data/lib/ccs/components/ccs/header/navigation.rb +85 -84
- data/lib/ccs/components/ccs/header/service_authentication.rb +35 -34
- data/lib/ccs/components/ccs/header.rb +87 -85
- data/lib/ccs/components/ccs/logo.rb +36 -34
- data/lib/ccs/components/govuk/accordion/section/content.rb +42 -42
- data/lib/ccs/components/govuk/accordion/section/header.rb +48 -48
- data/lib/ccs/components/govuk/accordion/section.rb +49 -48
- data/lib/ccs/components/govuk/accordion.rb +43 -41
- data/lib/ccs/components/govuk/back_link.rb +39 -37
- data/lib/ccs/components/govuk/breadcrumbs/link.rb +42 -40
- data/lib/ccs/components/govuk/breadcrumbs.rb +40 -38
- data/lib/ccs/components/govuk/button.rb +83 -81
- data/lib/ccs/components/govuk/cookie_banner/action.rb +45 -43
- data/lib/ccs/components/govuk/cookie_banner/message.rb +57 -55
- data/lib/ccs/components/govuk/cookie_banner.rb +40 -38
- data/lib/ccs/components/govuk/details.rb +38 -36
- data/lib/ccs/components/govuk/error_message.rb +46 -44
- data/lib/ccs/components/govuk/error_summary/item.rb +41 -39
- data/lib/ccs/components/govuk/error_summary.rb +49 -47
- data/lib/ccs/components/govuk/field/input/character_count.rb +101 -99
- data/lib/ccs/components/govuk/field/input/file_upload.rb +29 -27
- data/lib/ccs/components/govuk/field/input/select.rb +61 -59
- data/lib/ccs/components/govuk/field/input/text_input/fix.rb +39 -37
- data/lib/ccs/components/govuk/field/input/text_input.rb +75 -73
- data/lib/ccs/components/govuk/field/input/textarea.rb +43 -41
- data/lib/ccs/components/govuk/field/input.rb +46 -44
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +43 -41
- data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +48 -46
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +68 -66
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +29 -27
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +26 -24
- data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +32 -30
- data/lib/ccs/components/govuk/field/inputs/item/divider.rb +39 -37
- data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +27 -25
- data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +26 -24
- data/lib/ccs/components/govuk/field/inputs/item/radio.rb +32 -30
- data/lib/ccs/components/govuk/field/inputs/item.rb +100 -98
- data/lib/ccs/components/govuk/field/inputs/radios.rb +43 -41
- data/lib/ccs/components/govuk/field/inputs.rb +42 -40
- data/lib/ccs/components/govuk/field.rb +90 -88
- data/lib/ccs/components/govuk/fieldset/legend.rb +50 -48
- data/lib/ccs/components/govuk/fieldset.rb +40 -38
- data/lib/ccs/components/govuk/footer/link.rb +41 -39
- data/lib/ccs/components/govuk/footer/meta.rb +49 -48
- data/lib/ccs/components/govuk/footer/navigation.rb +51 -50
- data/lib/ccs/components/govuk/footer.rb +105 -103
- data/lib/ccs/components/govuk/form_group.rb +45 -43
- data/lib/ccs/components/govuk/header/link.rb +41 -39
- data/lib/ccs/components/govuk/header/navigation.rb +54 -53
- data/lib/ccs/components/govuk/header.rb +84 -82
- data/lib/ccs/components/govuk/hint.rb +33 -31
- data/lib/ccs/components/govuk/inset_text.rb +39 -37
- data/lib/ccs/components/govuk/label.rb +61 -59
- data/lib/ccs/components/govuk/notification_banner.rb +83 -81
- data/lib/ccs/components/govuk/pagination/increment/next.rb +29 -27
- data/lib/ccs/components/govuk/pagination/increment/previous.rb +28 -26
- data/lib/ccs/components/govuk/pagination/increment.rb +78 -76
- data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +17 -15
- data/lib/ccs/components/govuk/pagination/item/form.rb +34 -32
- data/lib/ccs/components/govuk/pagination/item/tag.rb +33 -31
- data/lib/ccs/components/govuk/pagination/item.rb +47 -45
- data/lib/ccs/components/govuk/pagination.rb +69 -67
- data/lib/ccs/components/govuk/panel.rb +49 -47
- data/lib/ccs/components/govuk/phase_banner.rb +50 -48
- data/lib/ccs/components/govuk/skip_link.rb +39 -37
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +40 -38
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +30 -28
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +28 -26
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +47 -45
- data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +49 -47
- data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +44 -42
- data/lib/ccs/components/govuk/step_by_step_navigation.rb +41 -39
- data/lib/ccs/components/govuk/summary_list/action/link.rb +46 -44
- data/lib/ccs/components/govuk/summary_list/card/actions.rb +38 -36
- data/lib/ccs/components/govuk/summary_list/card/title.rb +37 -35
- data/lib/ccs/components/govuk/summary_list/card.rb +48 -46
- data/lib/ccs/components/govuk/summary_list/row/actions.rb +38 -36
- data/lib/ccs/components/govuk/summary_list/row/key.rb +30 -28
- data/lib/ccs/components/govuk/summary_list/row/value.rb +30 -28
- data/lib/ccs/components/govuk/summary_list/row.rb +47 -45
- data/lib/ccs/components/govuk/summary_list.rb +48 -46
- data/lib/ccs/components/govuk/table/body/data_cell.rb +38 -36
- data/lib/ccs/components/govuk/table/body/head_cell.rb +37 -35
- data/lib/ccs/components/govuk/table/header/head_cell.rb +39 -37
- data/lib/ccs/components/govuk/table.rb +83 -81
- data/lib/ccs/components/govuk/tabs/panel.rb +47 -45
- data/lib/ccs/components/govuk/tabs/tab.rb +42 -40
- data/lib/ccs/components/govuk/tabs.rb +48 -46
- data/lib/ccs/components/govuk/tag.rb +39 -37
- data/lib/ccs/components/govuk/warning_text.rb +49 -47
- data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +16 -14
- data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +17 -15
- data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +17 -15
- data/lib/ccs/frontend_helpers/ccs_frontend.rb +1 -1
- data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +32 -30
- data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +38 -36
- data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +27 -25
- data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +18 -16
- data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +18 -16
- data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +24 -22
- data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +19 -17
- data/lib/ccs/frontend_helpers/version.rb +1 -1
- metadata +2 -2
@@ -3,63 +3,65 @@ require_relative 'item/divider'
|
|
3
3
|
require_relative 'item/checkbox/form'
|
4
4
|
require_relative 'item/checkbox/tag'
|
5
5
|
|
6
|
-
module CCS
|
7
|
-
module
|
8
|
-
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
module CCS
|
7
|
+
module Components
|
8
|
+
module GovUK
|
9
|
+
class Field < Base
|
10
|
+
class Inputs < Field
|
11
|
+
# = GOV.UK Checkboxes
|
12
|
+
#
|
13
|
+
# This is used for generating the checkboxes component from the
|
14
|
+
# {https://design-system.service.gov.uk/components/checkboxes GDS - Components - Checkboxes}
|
15
|
+
#
|
16
|
+
# @!attribute [r] checkbox_items
|
17
|
+
# @return [Array<Item::Divider|Item::Checkbox|Item::Checkbox>] An array of the initialised checkbox items
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
class Checkboxes < Inputs
|
20
|
+
private
|
20
21
|
|
21
|
-
|
22
|
+
attr_reader :checkbox_items
|
22
23
|
|
23
|
-
|
24
|
+
public
|
24
25
|
|
25
|
-
|
26
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# @param (see CCS::Components::GovUK::Field::Inputs#initialize)
|
29
|
+
# @param checkbox_items [Array<Hash>] an array of options for the checkboxes.
|
30
|
+
# See {Components::GovUK::Field::Inputs::Item::Checkbox#initialize Checkbox#initialize} for details of the items in the array.
|
31
|
+
#
|
32
|
+
# @option (see CCS::Components::GovUK::Field::Inputs#initialize)
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
def initialize(attribute:, checkbox_items:, **options)
|
35
|
+
super(attribute: attribute, **options)
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
if @options[:model] || @options[:form]
|
38
|
+
values = (@options[:model] || @options[:form].object).send(attribute) || []
|
39
|
+
checkbox_items.each { |checkbox_item| checkbox_item[:checked] = values.include?(checkbox_item[:value]) }
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
+
checkbox_item_class = @options[:form] ? Item::Checkbox::Form : Inputs::Item::Checkbox::Tag
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
@checkbox_items = checkbox_items.map { |checkbox_item| checkbox_item[:divider] ? Item::Divider.new(divider: checkbox_item[:divider], type: 'checkboxes') : checkbox_item_class.new(attribute: attribute, form: @options[:form], context: @context, **checkbox_item) }
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
# Generates the HTML for the GOV.UK Checkboxes component
|
50
|
+
#
|
51
|
+
# @return [ActiveSupport::SafeBuffer]
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def render
|
54
|
+
super() do
|
55
|
+
tag.div(**options[:attributes]) do
|
56
|
+
checkbox_items.each { |checkbox_item| concat(checkbox_item.render) }
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
|
-
end
|
59
60
|
|
60
|
-
|
61
|
+
# The default attributes for the checkboxes
|
61
62
|
|
62
|
-
|
63
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes', data: { module: 'govuk-checkboxes' } }.freeze
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -1,59 +1,61 @@
|
|
1
1
|
require_relative '../date_input'
|
2
2
|
require_relative '../../input/text_input'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
class
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
# This is used to generate an individual date input item
|
12
|
-
#
|
13
|
-
# @!attribute [r] input
|
14
|
-
# @return [TextInput] The initialised text input for the date item
|
15
|
-
|
16
|
-
class Item
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :input
|
23
|
-
|
24
|
-
public
|
25
|
-
|
26
|
-
# rubocop:disable Metrics/ParameterLists
|
27
|
-
|
28
|
-
# @param attribute [String,Symbol] the attribute for the date inputs
|
29
|
-
# @param name [String] the name of the date input item
|
30
|
-
# @param input [Hash] options for the input of the date input item, see {CCS::Components::GovUK::Field::Input::TextInput#initialize TextInput#initialize} for more details.
|
31
|
-
# @param label [Hash] options for the label of the date input item, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
|
32
|
-
# @param context [ActionView::Base] the view context
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class Field < Base
|
8
|
+
class Inputs < Field
|
9
|
+
class DateInput < Inputs
|
10
|
+
# = GOV.UK Date Inputs item
|
33
11
|
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
12
|
+
# This is used to generate an individual date input item
|
13
|
+
#
|
14
|
+
# @!attribute [r] input
|
15
|
+
# @return [TextInput] The initialised text input for the date item
|
37
16
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
(input[:attributes] ||= {})[:inputmode] ||= 'numeric'
|
17
|
+
class Item
|
18
|
+
include ActionView::Context
|
19
|
+
include ActionView::Helpers
|
42
20
|
|
43
|
-
|
44
|
-
label[:classes] = 'govuk-date-input__label'
|
21
|
+
private
|
45
22
|
|
46
|
-
|
47
|
-
end
|
23
|
+
attr_reader :input
|
48
24
|
|
49
|
-
|
25
|
+
public
|
50
26
|
|
51
|
-
|
52
|
-
|
53
|
-
|
27
|
+
# rubocop:disable Metrics/ParameterLists
|
28
|
+
|
29
|
+
# @param attribute [String,Symbol] the attribute for the date inputs
|
30
|
+
# @param name [String] the name of the date input item
|
31
|
+
# @param input [Hash] options for the input of the date input item, see {CCS::Components::GovUK::Field::Input::TextInput#initialize TextInput#initialize} for more details.
|
32
|
+
# @param label [Hash] options for the label of the date input item, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
|
33
|
+
# @param context [ActionView::Base] the view context
|
34
|
+
#
|
35
|
+
# @option options [Hash] error_message used as a flag to add the error classes to the item
|
36
|
+
# @option options [ActiveModel] :model (nil) optional model used to create the field
|
37
|
+
# @option options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create the field
|
38
|
+
|
39
|
+
def initialize(attribute:, name:, context:, input: {}, label: {}, **options)
|
40
|
+
input[:classes] = "govuk-date-input__input #{input[:classes]}".rstrip
|
41
|
+
input[:classes] << ' govuk-input--error' if options[:error_message]
|
42
|
+
(input[:attributes] ||= {})[:inputmode] ||= 'numeric'
|
43
|
+
|
44
|
+
label[:text] ||= name.capitalize
|
45
|
+
label[:classes] = 'govuk-date-input__label'
|
46
|
+
|
47
|
+
@input = Input::TextInput.new(attribute: "#{attribute}_#{name}", label: label, model: options[:model], form: options[:form], context: context, **input)
|
48
|
+
end
|
49
|
+
|
50
|
+
# rubocop:enable Metrics/ParameterLists
|
51
|
+
|
52
|
+
# Generates the HTML for the date input item
|
53
|
+
#
|
54
|
+
# @return [ActiveSupport::SafeBuffer]
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
def render
|
57
|
+
tag.div(input.render, class: 'govuk-date-input__item')
|
58
|
+
end
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
@@ -1,84 +1,86 @@
|
|
1
1
|
require_relative '../input'
|
2
2
|
require_relative 'date_input/item'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
# This is used for generating the date input component from the
|
11
|
-
# {https://design-system.service.gov.uk/components/date-input GDS - Components - Date Input}
|
12
|
-
#
|
13
|
-
# @!attribute [r] date_input_items
|
14
|
-
# @return [Array<DateInput::Item>] An array of the initialised date input items
|
15
|
-
|
16
|
-
class DateInput < Inputs
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :date_input_items
|
20
|
-
|
21
|
-
public
|
22
|
-
|
23
|
-
# @param (see CCS::Components::GovUK::Field::Inputs#initialize)
|
24
|
-
# @param date_items [Array<Hash>] an array of options for the date items.
|
25
|
-
# See {Components::GovUK::Field::Inputs::DateInput::Item#initialize Item#initialize} for details of the items in the array.
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class Field < Base
|
8
|
+
class Inputs < Field
|
9
|
+
# = GOV.UK Date Input
|
26
10
|
#
|
27
|
-
#
|
11
|
+
# This is used for generating the date input component from the
|
12
|
+
# {https://design-system.service.gov.uk/components/date-input GDS - Components - Date Input}
|
13
|
+
#
|
14
|
+
# @!attribute [r] date_input_items
|
15
|
+
# @return [Array<DateInput::Item>] An array of the initialised date input items
|
28
16
|
|
29
|
-
|
30
|
-
|
17
|
+
class DateInput < Inputs
|
18
|
+
private
|
31
19
|
|
32
|
-
|
20
|
+
attr_reader :date_input_items
|
33
21
|
|
34
|
-
|
22
|
+
public
|
35
23
|
|
36
|
-
@
|
37
|
-
|
24
|
+
# @param (see CCS::Components::GovUK::Field::Inputs#initialize)
|
25
|
+
# @param date_items [Array<Hash>] an array of options for the date items.
|
26
|
+
# See {Components::GovUK::Field::Inputs::DateInput::Item#initialize Item#initialize} for details of the items in the array.
|
27
|
+
#
|
28
|
+
# @option (see CCS::Components::GovUK::Field::Inputs#initialize)
|
38
29
|
|
39
|
-
|
40
|
-
|
41
|
-
# @return [ActiveSupport::SafeBuffer]
|
30
|
+
def initialize(attribute:, date_items: default_date_items, **options)
|
31
|
+
(options[:fieldset][:attributes] ||= {})[:role] = 'group'
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
date_input_items.each { |date_input_item| concat(date_input_item.render) }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
33
|
+
super(attribute: attribute, **options)
|
34
|
+
|
35
|
+
# date_items ||= default_date_items
|
50
36
|
|
51
|
-
|
37
|
+
@date_input_items = date_items.map { |date_input_item| Item.new(attribute: attribute, error_message: @error_message, model: @options[:model], form: @options[:form], context: @context, **date_input_item) }
|
38
|
+
end
|
52
39
|
|
53
|
-
|
40
|
+
# Generates the HTML for the GOV.UK date input component
|
41
|
+
#
|
42
|
+
# @return [ActiveSupport::SafeBuffer]
|
54
43
|
|
55
|
-
|
44
|
+
def render
|
45
|
+
super() do
|
46
|
+
tag.div(**options[:attributes]) do
|
47
|
+
date_input_items.each { |date_input_item| concat(date_input_item.render) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
52
|
+
# The default attributes for the date input
|
53
|
+
|
54
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-date-input' }.freeze
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
# The default date items used if no date items are provided
|
59
|
+
#
|
60
|
+
# @return [Array<Hash>]
|
61
|
+
|
62
|
+
def default_date_items
|
63
|
+
[
|
64
|
+
{
|
65
|
+
name: 'day',
|
66
|
+
input: {
|
67
|
+
classes: 'govuk-input--width-2'
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
name: 'month',
|
72
|
+
input: {
|
73
|
+
classes: 'govuk-input--width-2'
|
74
|
+
}
|
75
|
+
},
|
76
|
+
{
|
77
|
+
name: 'year',
|
78
|
+
input: {
|
79
|
+
classes: 'govuk-input--width-4'
|
80
|
+
}
|
67
81
|
}
|
68
|
-
|
69
|
-
|
70
|
-
name: 'month',
|
71
|
-
input: {
|
72
|
-
classes: 'govuk-input--width-2'
|
73
|
-
}
|
74
|
-
},
|
75
|
-
{
|
76
|
-
name: 'year',
|
77
|
-
input: {
|
78
|
-
classes: 'govuk-input--width-4'
|
79
|
-
}
|
80
|
-
}
|
81
|
-
]
|
82
|
+
]
|
83
|
+
end
|
82
84
|
end
|
83
85
|
end
|
84
86
|
end
|
@@ -1,39 +1,41 @@
|
|
1
1
|
require_relative '../checkbox'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
class
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
# This is used to generate an individual checkbox item using +form.check_box+
|
12
|
-
|
13
|
-
class Form < Checkbox
|
14
|
-
# @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Field < Base
|
7
|
+
class Inputs < Field
|
8
|
+
class Item < Base
|
9
|
+
class Checkbox < Item
|
10
|
+
# = GOV.UK Field Inputs Checkbox form tag
|
15
11
|
#
|
16
|
-
#
|
12
|
+
# This is used to generate an individual checkbox item using +form.check_box+
|
17
13
|
|
18
|
-
|
19
|
-
|
14
|
+
class Form < Checkbox
|
15
|
+
# @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
|
20
18
|
|
21
|
-
(label
|
22
|
-
|
19
|
+
def initialize(attribute:, label:, **options)
|
20
|
+
super(attribute: attribute, label: label, **options)
|
23
21
|
|
24
|
-
|
25
|
-
|
22
|
+
(label[:attributes] ||= {})[:value] = @value
|
23
|
+
label[:attributes][:for] = @options[:attributes][:id] if @options[:attributes][:id]
|
26
24
|
|
27
|
-
|
28
|
-
|
25
|
+
@options[:attributes][:multiple] = true
|
26
|
+
@options[:attributes][:include_hidden] = false
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
@label = Label.new(attribute: attribute, form: @options[:form], context: @context, **label)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Generates the HTML for the checkbox input
|
32
|
+
#
|
33
|
+
# @return [ActiveSupport::SafeBuffer]
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def render
|
36
|
+
super() do
|
37
|
+
@options[:form].check_box(@attribute, @options[:attributes], @value)
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -1,35 +1,37 @@
|
|
1
1
|
require_relative '../checkbox'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
class
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
# This is used to generate an individual checkbox item using +check_box_tag+
|
12
|
-
|
13
|
-
class Tag < Checkbox
|
14
|
-
# @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Field < Base
|
7
|
+
class Inputs < Field
|
8
|
+
class Item < Base
|
9
|
+
class Checkbox < Item
|
10
|
+
# = GOV.UK Field Inputs Checkbox tag
|
15
11
|
#
|
16
|
-
#
|
12
|
+
# This is used to generate an individual checkbox item using +check_box_tag+
|
17
13
|
|
18
|
-
|
19
|
-
|
14
|
+
class Tag < Checkbox
|
15
|
+
# @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
|
20
18
|
|
21
|
-
|
19
|
+
def initialize(attribute:, label:, **options)
|
20
|
+
super(attribute: attribute, label: label, **options)
|
22
21
|
|
23
|
-
|
24
|
-
end
|
22
|
+
@options[:attributes][:id] ||= "#{sanitize_to_id(@attribute)}_#{sanitize_to_id(@value)}"
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
@label = Label.new(attribute: @options[:attributes][:id], context: @context, **label)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Generates the HTML for the checkbox input
|
28
|
+
#
|
29
|
+
# @return [ActiveSupport::SafeBuffer]
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def render
|
32
|
+
super() do
|
33
|
+
context.check_box_tag("#{@attribute}[]", @value, @options[:checked], **@options[:attributes])
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -1,45 +1,47 @@
|
|
1
1
|
require_relative '../item'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
# This is used to generate an individual checkbox item
|
11
|
-
|
12
|
-
class Checkbox < Item
|
13
|
-
# @param (see CCS::Components::GovUK::Field::Items::Item#initialize)
|
14
|
-
# label [Hash] attributes for the checkbox label, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Field < Base
|
7
|
+
class Inputs < Field
|
8
|
+
class Item < Base
|
9
|
+
# = GOV.UK Field Inputs Checkbox
|
15
10
|
#
|
16
|
-
#
|
11
|
+
# This is used to generate an individual checkbox item
|
17
12
|
|
18
|
-
|
19
|
-
|
13
|
+
class Checkbox < Item
|
14
|
+
# @param (see CCS::Components::GovUK::Field::Items::Item#initialize)
|
15
|
+
# label [Hash] attributes for the checkbox label, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
def initialize(attribute:, label:, **options)
|
20
|
+
super(attribute: attribute, **options)
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
# @yield the checkbox item input HTML
|
27
|
-
#
|
28
|
-
# @return [ActiveSupport::SafeBuffer]
|
22
|
+
label[:classes] = "govuk-checkboxes__label #{label[:classes]}".rstrip
|
23
|
+
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
# Generates the HTML to wrap arround a checkbox input
|
26
|
+
#
|
27
|
+
# @yield the checkbox item input HTML
|
28
|
+
#
|
29
|
+
# @return [ActiveSupport::SafeBuffer]
|
30
|
+
|
31
|
+
def render(&block)
|
32
|
+
tag.div(class: 'govuk-checkboxes__item') do
|
33
|
+
super(&block)
|
34
|
+
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
+
# The default attributes for the checkbox
|
37
38
|
|
38
|
-
|
39
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes__input' }.freeze
|
39
40
|
|
40
|
-
|
41
|
+
# The type of the input item
|
41
42
|
|
42
|
-
|
43
|
+
ITEM_TYPE = 'checkboxes'.freeze
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|