From 8ba8944770b13f957edac6fa2e9a7fc3f4c24418 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Sun, 9 Jun 2024 18:11:41 -0700 Subject: [PATCH] Apply form-range class to range inputs (#734) * Changed in CI Please review the changes in the files in this commit carefully, as they were automatically generated during CI. Run `git pull` to bring the changes into your local branch. Then, if you do not want the changes, run `git revert HEAD`. * Fix build (#733) * Found one place to remove old version of sqlite3 * Fix matrix * Sqlite versions differ by Rails version * Downgrade sprockets temporarily * Changed in CI Please review the changes in the files in this commit carefully, as they were automatically generated during CI. Run `git pull` to bring the changes into your local branch. Then, if you do not want the changes, run `git revert HEAD`. --------- Co-authored-by: github-actions * Patch top-level Gemfile for recent build issues * Fix form-range class --------- Co-authored-by: github-actions --- Gemfile | 7 ++++++- lib/bootstrap_form/inputs/base.rb | 5 +++-- lib/bootstrap_form/inputs/range_field.rb | 2 +- test/bootstrap_fields_test.rb | 10 ++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 70b52f6ad..853c12710 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,9 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval require "#{__dir__}/lib/bootstrap_form/version" gem "rails", BootstrapForm::REQUIRED_RAILS_VERSION -gem "sprockets-rails", require: "sprockets/railtie" +gem "sprockets-rails", "< 3.5.0", require: "sprockets/railtie" + +gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "sqlite3", "~> 1.4" diff --git a/lib/bootstrap_form/inputs/base.rb b/lib/bootstrap_form/inputs/base.rb index 5697e6a57..f0513c979 100644 --- a/lib/bootstrap_form/inputs/base.rb +++ b/lib/bootstrap_form/inputs/base.rb @@ -6,9 +6,10 @@ module Base extend ActiveSupport::Concern class_methods do - def bootstrap_field(field_name, control_class: nil) - define_method :"#{field_name}_with_bootstrap" do |name, options={ control_class: control_class }.compact| + def bootstrap_field(field_name) + define_method :"#{field_name}_with_bootstrap" do |name, options={}| warn_deprecated_layout_value(options) + options = options.reverse_merge(control_class: "form-range") if field_name == :range_field form_group_builder(name, options) do prepend_and_append_input(name, options) do options[:placeholder] ||= name if options[:floating] diff --git a/lib/bootstrap_form/inputs/range_field.rb b/lib/bootstrap_form/inputs/range_field.rb index 67453b714..125eba5b7 100644 --- a/lib/bootstrap_form/inputs/range_field.rb +++ b/lib/bootstrap_form/inputs/range_field.rb @@ -7,7 +7,7 @@ module RangeField include Base included do - bootstrap_field :range_field, control_class: "form-range" + bootstrap_field :range_field end end end diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index c936554f1..bf3a5d2fb 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -185,6 +185,16 @@ class BootstrapFieldsTest < ActionView::TestCase assert_equivalent_html expected, @builder.range_field(:misc) end + test "range fields are wrapped correctly with exta attributes" do + expected = <<~HTML +
+ + +
+ HTML + assert_equivalent_html expected, @builder.range_field(:misc, min: 0, max: 80) + end + test "search fields are wrapped correctly" do expected = <<~HTML