bootstrap_form 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -0
  3. data/.rubocop.yml +3 -2
  4. data/.travis.yml +7 -1
  5. data/CHANGELOG.md +15 -1
  6. data/CONTRIBUTING.md +11 -0
  7. data/Dangerfile +4 -4
  8. data/Gemfile +7 -2
  9. data/OLD-README.md +795 -0
  10. data/README.md +150 -93
  11. data/Rakefile +2 -4
  12. data/bootstrap_form.gemspec +2 -1
  13. data/demo/.postcssrc.yml +3 -0
  14. data/demo/app/assets/config/manifest.js +2 -0
  15. data/demo/app/assets/stylesheets/actiontext.scss +38 -0
  16. data/demo/app/assets/stylesheets/application.scss +1 -0
  17. data/demo/app/helpers/bootstrap_helper.rb +16 -10
  18. data/demo/app/javascript/channels/consumer.js +6 -0
  19. data/demo/app/javascript/channels/index.js +5 -0
  20. data/demo/app/javascript/packs/application.js +11 -0
  21. data/demo/app/models/user.rb +2 -0
  22. data/demo/app/views/active_storage/blobs/_blob.html.erb +14 -0
  23. data/demo/app/views/bootstrap/form.html.erb +2 -1
  24. data/demo/app/views/layouts/application.html.erb +3 -0
  25. data/demo/bin/webpack +15 -0
  26. data/demo/bin/webpack-dev-server +15 -0
  27. data/demo/config/application.rb +2 -3
  28. data/demo/config/environments/development.rb +3 -1
  29. data/demo/config/environments/production.rb +48 -0
  30. data/demo/config/webpack/development.js +5 -0
  31. data/demo/config/webpack/environment.js +3 -0
  32. data/demo/config/webpack/production.js +5 -0
  33. data/demo/config/webpack/test.js +5 -0
  34. data/demo/config/webpacker.yml +92 -0
  35. data/demo/db/schema.rb +63 -18
  36. data/demo/package.json +13 -1
  37. data/demo/test/fixtures/action_text/rich_texts.yml +4 -0
  38. data/demo/yarn.lock +6257 -0
  39. data/lib/bootstrap_form.rb +34 -8
  40. data/lib/bootstrap_form/action_view_extensions/form_helper.rb +71 -0
  41. data/lib/bootstrap_form/components.rb +17 -0
  42. data/lib/bootstrap_form/components/hints.rb +60 -0
  43. data/lib/bootstrap_form/components/labels.rb +56 -0
  44. data/lib/bootstrap_form/components/layout.rb +39 -0
  45. data/lib/bootstrap_form/components/validation.rb +61 -0
  46. data/lib/bootstrap_form/engine.rb +10 -0
  47. data/lib/bootstrap_form/form_builder.rb +54 -524
  48. data/lib/bootstrap_form/form_group.rb +64 -0
  49. data/lib/bootstrap_form/form_group_builder.rb +103 -0
  50. data/lib/bootstrap_form/helpers.rb +9 -0
  51. data/lib/bootstrap_form/helpers/bootstrap.rb +39 -31
  52. data/lib/bootstrap_form/inputs.rb +40 -0
  53. data/lib/bootstrap_form/inputs/base.rb +40 -0
  54. data/lib/bootstrap_form/inputs/check_box.rb +89 -0
  55. data/lib/bootstrap_form/inputs/collection_check_boxes.rb +23 -0
  56. data/lib/bootstrap_form/inputs/collection_radio_buttons.rb +21 -0
  57. data/lib/bootstrap_form/inputs/collection_select.rb +25 -0
  58. data/lib/bootstrap_form/inputs/color_field.rb +14 -0
  59. data/lib/bootstrap_form/inputs/date_field.rb +14 -0
  60. data/lib/bootstrap_form/inputs/date_select.rb +14 -0
  61. data/lib/bootstrap_form/inputs/datetime_field.rb +14 -0
  62. data/lib/bootstrap_form/inputs/datetime_local_field.rb +14 -0
  63. data/lib/bootstrap_form/inputs/datetime_select.rb +14 -0
  64. data/lib/bootstrap_form/inputs/email_field.rb +14 -0
  65. data/lib/bootstrap_form/inputs/file_field.rb +35 -0
  66. data/lib/bootstrap_form/inputs/grouped_collection_select.rb +29 -0
  67. data/lib/bootstrap_form/inputs/inputs_collection.rb +44 -0
  68. data/lib/bootstrap_form/inputs/month_field.rb +14 -0
  69. data/lib/bootstrap_form/inputs/number_field.rb +14 -0
  70. data/lib/bootstrap_form/inputs/password_field.rb +14 -0
  71. data/lib/bootstrap_form/inputs/phone_field.rb +14 -0
  72. data/lib/bootstrap_form/inputs/radio_button.rb +77 -0
  73. data/lib/bootstrap_form/inputs/range_field.rb +14 -0
  74. data/lib/bootstrap_form/inputs/rich_text_area.rb +23 -0
  75. data/lib/bootstrap_form/inputs/search_field.rb +14 -0
  76. data/lib/bootstrap_form/inputs/select.rb +22 -0
  77. data/lib/bootstrap_form/inputs/telephone_field.rb +14 -0
  78. data/lib/bootstrap_form/inputs/text_area.rb +14 -0
  79. data/lib/bootstrap_form/inputs/text_field.rb +14 -0
  80. data/lib/bootstrap_form/inputs/time_field.rb +14 -0
  81. data/lib/bootstrap_form/inputs/time_select.rb +14 -0
  82. data/lib/bootstrap_form/inputs/time_zone_select.rb +22 -0
  83. data/lib/bootstrap_form/inputs/url_field.rb +14 -0
  84. data/lib/bootstrap_form/inputs/week_field.rb +14 -0
  85. data/lib/bootstrap_form/version.rb +1 -1
  86. metadata +79 -6
  87. data/.rubocop_todo.yml +0 -104
  88. data/lib/bootstrap_form/aliasing.rb +0 -35
  89. data/lib/bootstrap_form/helper.rb +0 -52
@@ -1,35 +0,0 @@
1
- module BootstrapForm
2
- # This module implements the old ActiveSupport alias_method_chain feature
3
- # with a new name, and without the deprecation warnings. In ActiveSupport 5+,
4
- # this style of patching was deprecated in favor of Module.prepend. But
5
- # Module.prepend is not present in Ruby 1.9, which we would still like to
6
- # support. So we continue to use of alias_method_chain, albeit with a
7
- # different name to avoid collisions.
8
- module Aliasing
9
- # This code is copied and pasted from ActiveSupport, but with :bootstrap
10
- # hardcoded as the feature name, and with the deprecation warning removed.
11
- def bootstrap_method_alias(target)
12
- feature = :bootstrap
13
-
14
- # Strip out punctuation on predicates, bang or writer methods since
15
- # e.g. target?_without_feature is not a valid method name.
16
- aliased_target = target.to_s.sub(/([?!=])$/, "")
17
- punctuation = Regexp.last_match(1)
18
- yield(aliased_target, punctuation) if block_given?
19
-
20
- with_method = "#{aliased_target}_with_#{feature}#{punctuation}"
21
- without_method = "#{aliased_target}_without_#{feature}#{punctuation}"
22
-
23
- alias_method without_method, target
24
- alias_method target, with_method
25
-
26
- if public_method_defined?(without_method)
27
- public target
28
- elsif protected_method_defined?(without_method)
29
- protected target
30
- elsif private_method_defined?(without_method)
31
- private target
32
- end
33
- end
34
- end
35
- end
@@ -1,52 +0,0 @@
1
- module BootstrapForm
2
- module Helper
3
- def bootstrap_form_for(object, options={}, &block)
4
- options.reverse_merge!(builder: BootstrapForm::FormBuilder)
5
-
6
- options = process_options(options)
7
-
8
- temporarily_disable_field_error_proc do
9
- form_for(object, options, &block)
10
- end
11
- end
12
-
13
- def bootstrap_form_tag(options={}, &block)
14
- options[:acts_like_form_tag] = true
15
-
16
- bootstrap_form_for("", options, &block)
17
- end
18
-
19
- def bootstrap_form_with(options={}, &block)
20
- options.reverse_merge!(builder: BootstrapForm::FormBuilder)
21
-
22
- options = process_options(options)
23
-
24
- temporarily_disable_field_error_proc do
25
- form_with(options, &block)
26
- end
27
- end
28
-
29
- private
30
-
31
- def process_options(options)
32
- options[:html] ||= {}
33
- options[:html][:role] ||= "form"
34
-
35
- if options[:layout] == :inline
36
- options[:html][:class] = [options[:html][:class], "form-inline"].compact.join(" ")
37
- end
38
-
39
- options
40
- end
41
-
42
- public
43
-
44
- def temporarily_disable_field_error_proc
45
- original_proc = ActionView::Base.field_error_proc
46
- ActionView::Base.field_error_proc = proc { |input, _instance| input }
47
- yield
48
- ensure
49
- ActionView::Base.field_error_proc = original_proc
50
- end
51
- end
52
- end