rails_bootstrap_form 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -1
  3. data/CONTRIBUTING.md +146 -0
  4. data/Gemfile.lock +1 -1
  5. data/README.md +76 -44
  6. data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +5 -2
  7. data/lib/rails_bootstrap_form/field_wrapper_builder.rb +50 -49
  8. data/lib/rails_bootstrap_form/helpers/buttons.rb +3 -3
  9. data/lib/rails_bootstrap_form/helpers/choice.rb +81 -0
  10. data/lib/rails_bootstrap_form/helpers/help_text.rb +3 -3
  11. data/lib/rails_bootstrap_form/helpers/labels.rb +16 -16
  12. data/lib/rails_bootstrap_form/helpers.rb +10 -11
  13. data/lib/rails_bootstrap_form/input_group_builder.rb +14 -14
  14. data/lib/rails_bootstrap_form/inputs/base.rb +21 -18
  15. data/lib/rails_bootstrap_form/inputs/check_box.rb +12 -20
  16. data/lib/rails_bootstrap_form/inputs/collection_check_boxes.rb +10 -5
  17. data/lib/rails_bootstrap_form/inputs/collection_radio_buttons.rb +10 -5
  18. data/lib/rails_bootstrap_form/inputs/collection_select.rb +3 -3
  19. data/lib/rails_bootstrap_form/inputs/color_field.rb +9 -4
  20. data/lib/rails_bootstrap_form/inputs/grouped_collection_select.rb +3 -3
  21. data/lib/rails_bootstrap_form/inputs/radio_button.rb +11 -19
  22. data/lib/rails_bootstrap_form/inputs/range_field.rb +4 -4
  23. data/lib/rails_bootstrap_form/inputs/rich_text_area.rb +3 -3
  24. data/lib/rails_bootstrap_form/inputs/select.rb +3 -3
  25. data/lib/rails_bootstrap_form/inputs/time_zone_select.rb +3 -3
  26. data/lib/rails_bootstrap_form/inputs/weekday_select.rb +3 -3
  27. data/lib/rails_bootstrap_form/version.rb +1 -1
  28. metadata +4 -4
  29. data/lib/rails_bootstrap_form/helpers/check_box.rb +0 -86
  30. data/lib/rails_bootstrap_form/helpers/radio_button.rb +0 -82
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harshal LADHE (shivam091)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: generator_spec
@@ -63,6 +63,7 @@ files:
63
63
  - ".rspec"
64
64
  - CHANGELOG.md
65
65
  - CODE_OF_CONDUCT.md
66
+ - CONTRIBUTING.md
66
67
  - Gemfile
67
68
  - Gemfile.lock
68
69
  - LICENSE.txt
@@ -146,11 +147,10 @@ files:
146
147
  - lib/rails_bootstrap_form/field_wrapper_builder.rb
147
148
  - lib/rails_bootstrap_form/helpers.rb
148
149
  - lib/rails_bootstrap_form/helpers/buttons.rb
149
- - lib/rails_bootstrap_form/helpers/check_box.rb
150
+ - lib/rails_bootstrap_form/helpers/choice.rb
150
151
  - lib/rails_bootstrap_form/helpers/errors.rb
151
152
  - lib/rails_bootstrap_form/helpers/help_text.rb
152
153
  - lib/rails_bootstrap_form/helpers/labels.rb
153
- - lib/rails_bootstrap_form/helpers/radio_button.rb
154
154
  - lib/rails_bootstrap_form/helpers/required_field.rb
155
155
  - lib/rails_bootstrap_form/input_group_builder.rb
156
156
  - lib/rails_bootstrap_form/inputs.rb
@@ -1,86 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # -*- frozen_string_literal: true -*-
3
- # -*- warn_indent: true -*-
4
-
5
- module RailsBootstrapForm
6
- module Helpers
7
- module CheckBox
8
- extend ActiveSupport::Concern
9
-
10
- def self.included(base_class)
11
- def check_box_label(attribute, checked_value, options, bootstrap_options, &block)
12
- unless bootstrap_options.skip_label?
13
- label_options = {
14
- class: check_box_label_class(attribute, bootstrap_options, options)
15
- }
16
- label_options[:for] = options[:id] if options[:id].present?
17
-
18
- label_name = if options[:multiple]
19
- check_box_value(attribute, checked_value)
20
- else
21
- attribute
22
- end
23
-
24
- label_text = check_box_label_text(attribute, options, bootstrap_options, &block)
25
-
26
- label(label_name, label_text, label_options)
27
- end
28
- end
29
-
30
- def check_box_wrapper_options(bootstrap_options)
31
- wrapper_options = bootstrap_options.wrapper
32
-
33
- {}.tap do |option|
34
- option[:class] = check_box_wrapper_classes(bootstrap_options)
35
- option.merge!(wrapper_options.except(:class)) if wrapper_options.is_a?(Hash)
36
- end
37
- end
38
-
39
- def check_box_label_text(attribute, options, bootstrap_options, &block)
40
- block ? capture(&block) : label_text(attribute, bootstrap_options)
41
- end
42
-
43
- def check_box_value(attribute, value)
44
- # label's `for` attribute needs to match checkbox tag's id,
45
- # IE sanitized value, IE
46
- # https://github.com/rails/rails/blob/5-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L123-L125
47
- "#{attribute}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase}"
48
- end
49
-
50
- def check_box_classes(attribute, options)
51
- classes = Array(options[:class]) << "form-check-input"
52
- classes << "is-invalid" if is_invalid?(attribute)
53
- classes.flatten.compact
54
- end
55
-
56
- def check_box_label_class(attribute, bootstrap_options, options)
57
- classes = Array("form-check-label") << bootstrap_options.additional_label_class
58
- classes << "required" if is_field_required?(attribute, options) && !bootstrap_options.inline?
59
- classes << "is-invalid" if is_invalid?(attribute)
60
- classes << bootstrap_options.hide_class if bootstrap_options.hide_label?
61
- classes.flatten.compact
62
- end
63
-
64
- def check_box_wrapper_classes(bootstrap_options)
65
- classes = Array("form-check")
66
- classes << "form-switch" if bootstrap_options.switch?
67
- classes << "form-check-inline" if bootstrap_options.inline?
68
- if (bootstrap_options.layout_vertical? && !bootstrap_options.inline?)
69
- classes << "mb-3"
70
- end
71
- classes << bootstrap_options.wrapper[:class]
72
- classes.flatten.compact
73
- end
74
-
75
- def check_box_container_classes(bootstrap_options)
76
- classes = Array(bootstrap_options.field_col_wrapper_class)
77
- classes << field_offset_class(bootstrap_options.label_col_wrapper_class)
78
- classes.flatten.compact
79
- end
80
-
81
- private :check_box_label, :check_box_classes, :check_box_label_class,
82
- :check_box_wrapper_classes, :check_box_container_classes
83
- end
84
- end
85
- end
86
- end
@@ -1,82 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # -*- frozen_string_literal: true -*-
3
- # -*- warn_indent: true -*-
4
-
5
- module RailsBootstrapForm
6
- module Helpers
7
- module RadioButton
8
- extend ActiveSupport::Concern
9
-
10
- def self.included(base_class)
11
- def radio_button_label(attribute, value, options, bootstrap_options)
12
- unless bootstrap_options.skip_label?
13
- label_options = {
14
- value: value,
15
- class: radio_button_label_class(attribute, bootstrap_options, options)
16
- }
17
- label_options[:for] = options[:id] if options[:id].present?
18
-
19
- label_name = if options[:multiple]
20
- radio_button_value(attribute, checked_value)
21
- else
22
- attribute
23
- end
24
-
25
- label_text = label_text(attribute, bootstrap_options)
26
-
27
- label(label_name, label_text, label_options)
28
- end
29
- end
30
-
31
- def radio_button_wrapper_options(bootstrap_options)
32
- wrapper_options = bootstrap_options.wrapper
33
-
34
- {}.tap do |option|
35
- option[:class] = radio_button_wrapper_classes(bootstrap_options)
36
- option.merge!(wrapper_options.except(:class)) if wrapper_options.is_a?(Hash)
37
- end
38
- end
39
-
40
- def radio_button_value(attribute, value)
41
- # label's `for` attribute needs to match checkbox tag's id,
42
- # IE sanitized value, IE
43
- # https://github.com/rails/rails/blob/5-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L123-L125
44
- "#{attribute}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase}"
45
- end
46
-
47
- def radio_button_classes(attribute, options)
48
- classes = Array(options[:class]) << "form-check-input"
49
- classes << "is-invalid" if is_invalid?(attribute)
50
- classes.flatten.compact
51
- end
52
-
53
- def radio_button_label_class(attribute, bootstrap_options, options)
54
- classes = Array("form-check-label") << bootstrap_options.additional_label_class
55
- classes << "required" if is_field_required?(attribute, options) && !bootstrap_options.inline?
56
- classes << "is-invalid" if is_invalid?(attribute)
57
- classes << bootstrap_options.hide_class if bootstrap_options.hide_label?
58
- classes.flatten.compact
59
- end
60
-
61
- def radio_button_wrapper_classes(bootstrap_options)
62
- classes = Array("form-check")
63
- classes << "form-check-inline" if bootstrap_options.inline?
64
- if (bootstrap_options.layout_vertical? && !bootstrap_options.inline?)
65
- classes << "mb-3"
66
- end
67
- classes << bootstrap_options.wrapper[:class]
68
- classes.flatten.compact
69
- end
70
-
71
- def radio_button_container_classes(bootstrap_options)
72
- classes = Array(bootstrap_options.field_col_wrapper_class)
73
- classes << field_offset_class(bootstrap_options.label_col_wrapper_class)
74
- classes.flatten.compact
75
- end
76
-
77
- private :radio_button_label, :radio_button_classes, :radio_button_label_class,
78
- :radio_button_wrapper_classes, :radio_button_container_classes
79
- end
80
- end
81
- end
82
- end