Skip to content

Commit

Permalink
Apply form-range class to range inputs (#734)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Patch top-level Gemfile for recent build issues

* Fix form-range class

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
lcreid and github-actions authored Jun 10, 2024
1 parent 109edc4 commit 8ba8944
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 3 additions & 2 deletions lib/bootstrap_form/inputs/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/bootstrap_form/inputs/range_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/bootstrap_fields_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<div class="mb-3">
<label class="form-label" for="user_misc">Misc</label>
<input min="0" max="80" class="form-range" id="user_misc" name="user[misc]" type="range" />
</div>
HTML
assert_equivalent_html expected, @builder.range_field(:misc, min: 0, max: 80)
end

test "search fields are wrapped correctly" do
expected = <<~HTML
<div class="mb-3">
Expand Down

0 comments on commit 8ba8944

Please sign in to comment.