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.
- checksums.yaml +4 -4
- data/.gitignore +18 -0
- data/.rubocop.yml +3 -2
- data/.travis.yml +7 -1
- data/CHANGELOG.md +15 -1
- data/CONTRIBUTING.md +11 -0
- data/Dangerfile +4 -4
- data/Gemfile +7 -2
- data/OLD-README.md +795 -0
- data/README.md +150 -93
- data/Rakefile +2 -4
- data/bootstrap_form.gemspec +2 -1
- data/demo/.postcssrc.yml +3 -0
- data/demo/app/assets/config/manifest.js +2 -0
- data/demo/app/assets/stylesheets/actiontext.scss +38 -0
- data/demo/app/assets/stylesheets/application.scss +1 -0
- data/demo/app/helpers/bootstrap_helper.rb +16 -10
- data/demo/app/javascript/channels/consumer.js +6 -0
- data/demo/app/javascript/channels/index.js +5 -0
- data/demo/app/javascript/packs/application.js +11 -0
- data/demo/app/models/user.rb +2 -0
- data/demo/app/views/active_storage/blobs/_blob.html.erb +14 -0
- data/demo/app/views/bootstrap/form.html.erb +2 -1
- data/demo/app/views/layouts/application.html.erb +3 -0
- data/demo/bin/webpack +15 -0
- data/demo/bin/webpack-dev-server +15 -0
- data/demo/config/application.rb +2 -3
- data/demo/config/environments/development.rb +3 -1
- data/demo/config/environments/production.rb +48 -0
- data/demo/config/webpack/development.js +5 -0
- data/demo/config/webpack/environment.js +3 -0
- data/demo/config/webpack/production.js +5 -0
- data/demo/config/webpack/test.js +5 -0
- data/demo/config/webpacker.yml +92 -0
- data/demo/db/schema.rb +63 -18
- data/demo/package.json +13 -1
- data/demo/test/fixtures/action_text/rich_texts.yml +4 -0
- data/demo/yarn.lock +6257 -0
- data/lib/bootstrap_form.rb +34 -8
- data/lib/bootstrap_form/action_view_extensions/form_helper.rb +71 -0
- data/lib/bootstrap_form/components.rb +17 -0
- data/lib/bootstrap_form/components/hints.rb +60 -0
- data/lib/bootstrap_form/components/labels.rb +56 -0
- data/lib/bootstrap_form/components/layout.rb +39 -0
- data/lib/bootstrap_form/components/validation.rb +61 -0
- data/lib/bootstrap_form/engine.rb +10 -0
- data/lib/bootstrap_form/form_builder.rb +54 -524
- data/lib/bootstrap_form/form_group.rb +64 -0
- data/lib/bootstrap_form/form_group_builder.rb +103 -0
- data/lib/bootstrap_form/helpers.rb +9 -0
- data/lib/bootstrap_form/helpers/bootstrap.rb +39 -31
- data/lib/bootstrap_form/inputs.rb +40 -0
- data/lib/bootstrap_form/inputs/base.rb +40 -0
- data/lib/bootstrap_form/inputs/check_box.rb +89 -0
- data/lib/bootstrap_form/inputs/collection_check_boxes.rb +23 -0
- data/lib/bootstrap_form/inputs/collection_radio_buttons.rb +21 -0
- data/lib/bootstrap_form/inputs/collection_select.rb +25 -0
- data/lib/bootstrap_form/inputs/color_field.rb +14 -0
- data/lib/bootstrap_form/inputs/date_field.rb +14 -0
- data/lib/bootstrap_form/inputs/date_select.rb +14 -0
- data/lib/bootstrap_form/inputs/datetime_field.rb +14 -0
- data/lib/bootstrap_form/inputs/datetime_local_field.rb +14 -0
- data/lib/bootstrap_form/inputs/datetime_select.rb +14 -0
- data/lib/bootstrap_form/inputs/email_field.rb +14 -0
- data/lib/bootstrap_form/inputs/file_field.rb +35 -0
- data/lib/bootstrap_form/inputs/grouped_collection_select.rb +29 -0
- data/lib/bootstrap_form/inputs/inputs_collection.rb +44 -0
- data/lib/bootstrap_form/inputs/month_field.rb +14 -0
- data/lib/bootstrap_form/inputs/number_field.rb +14 -0
- data/lib/bootstrap_form/inputs/password_field.rb +14 -0
- data/lib/bootstrap_form/inputs/phone_field.rb +14 -0
- data/lib/bootstrap_form/inputs/radio_button.rb +77 -0
- data/lib/bootstrap_form/inputs/range_field.rb +14 -0
- data/lib/bootstrap_form/inputs/rich_text_area.rb +23 -0
- data/lib/bootstrap_form/inputs/search_field.rb +14 -0
- data/lib/bootstrap_form/inputs/select.rb +22 -0
- data/lib/bootstrap_form/inputs/telephone_field.rb +14 -0
- data/lib/bootstrap_form/inputs/text_area.rb +14 -0
- data/lib/bootstrap_form/inputs/text_field.rb +14 -0
- data/lib/bootstrap_form/inputs/time_field.rb +14 -0
- data/lib/bootstrap_form/inputs/time_select.rb +14 -0
- data/lib/bootstrap_form/inputs/time_zone_select.rb +22 -0
- data/lib/bootstrap_form/inputs/url_field.rb +14 -0
- data/lib/bootstrap_form/inputs/week_field.rb +14 -0
- data/lib/bootstrap_form/version.rb +1 -1
- metadata +79 -6
- data/.rubocop_todo.yml +0 -104
- data/lib/bootstrap_form/aliasing.rb +0 -35
- 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
|