Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors on invalid feedback #580

Merged

Conversation

cseelus
Copy link
Contributor

@cseelus cseelus commented Apr 3, 2021

Follow up on issue 579.

Took a little while, since I first wanted the project we use bootstrap_form with, to use Bootstrap 5 in a new development branch. So far the transition went smoother than the upgrade from 3 to 4, although it is far from complete.

The bootstrap-5 branch of bootstrap_form works surprisingly well already.

@cseelus cseelus closed this Apr 3, 2021
@cseelus cseelus reopened this Apr 3, 2021
@cseelus cseelus changed the base branch from master to bootstrap-5 April 3, 2021 13:53
@bootstrap-ruby-bot
Copy link

1 Warning
⚠️ Please update CHANGELOG.md with a description of your changes. If this PR is not a user-facing change (e.g. just refactoring), you can disregard this.

Here's an example of a CHANGELOG.md entry (place it immediately under the * Your contribution here! line):

* [#580](https://github.com/bootstrap-ruby/bootstrap_form/pull/580): Errors on invalid feedback - [@cseelus](https://github.com/cseelus).

Generated by 🚫 Danger

Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good so far. Could you please add some documentation in UPGRADE-5.0.md to describe this change and perhaps tell people what they would have to do if they can't or don't want to change their CSS from the previous version? Thanks in advance.

@cseelus
Copy link
Contributor Author

cseelus commented Apr 14, 2021

I would add the following text to the bottom of UPGRADE-5.0.md:


Different behavior for errors_on helper

The errors_on helper now wraps the error message in a CSS class invalid-feedback, instead of alert and alert-danger, as before.

This will display the error as any other Bootstrap inline form error, instead of displaying it as an Bootstrap alert.


Could you elaborate on what you mean by "tell people what they would have to do if they can't or don't want to change their CSS from the previous version"? Then I will add this also.
As far as I understand it, this should work without any extra CSS (as with < 5.0).

@lcreid
Copy link
Contributor

lcreid commented Apr 15, 2021

Could you elaborate on what you mean by "tell people what they would have to do if they can't or don't want to change their CSS from the previous version"? Then I will add this also.
As far as I understand it, this should work without any extra CSS (as with < 5.0).

I'm thinking of the (unlikely) case where someone might have deliberately styled the CSS classes differently. Then they would have to do something to get the same results as before. And if they can't do anything about it, perhaps they should be able to. Maybe we could add a class option to errors_on, where they can specify a class or classes that override the default invalid-feedback.

It may seem like an unlikely case, but I think it's good practice in general to give people a way to keep using our gem,. Another solution might be to document that if the new behaviour of errors_on is unacceptable, they can hard-code the HTML and CSS in place of using errors_on, or write their own method that replaces it. But I think adding a class argument to the method (and documenting it) feels like not too much effort. Let me know if I'm wrong.

What you wrote above is just perfect for what I originally asked for.

Thanks again for taking the time to contribute to bootstrap_form.

@cseelus
Copy link
Contributor Author

cseelus commented Apr 18, 2021

So you mean an option like class: 'foo', that will just override '.invalid-feedback'?

Regarding the custom helper idea you asked for, I played around with the idea for a bit:

  def custom_errors_on(form, name, options = {})
    return if form.object.errors[name].blank?

    tag.div(class: 'alert alert-danger') do
      # hidden input tag is needed for the 'invalid-feedback' to be shown
      concat tag.input(type: 'hidden', class: 'is-invalid')
      concat form.errors_on(name, options)
    end
  end

@lcreid
Copy link
Contributor

lcreid commented Apr 20, 2021

So you mean an option like class: 'foo', that will just override '.invalid-feedback'?

Yeah, basically something like that. BTW, I hope I'm not frustrating you, but I really don't have the cycles to think through the details, so I like to year what you propose. But, yeah, class: 'foo' is probably all we need here. (And see my comment at the end.)

Regarding the custom helper idea you asked for, I played around with the idea for a bit:

  def custom_errors_on(form, name, options = {})
    return if form.object.errors[name].blank?

    tag.div(class: 'alert alert-danger') do
      # hidden input tag is needed for the 'invalid-feedback' to be shown
      concat tag.input(type: 'hidden', class: 'is-invalid')
      concat form.errors_on(name, options)
    end
  end

Thanks for doing the work to play with this. It seems to me like adding the class option to errors_on, plus documentation, isn't very much work compared to having to tell people how to write their own method to override ours. Maybe we could just add the class option? What do you think?

@cseelus
Copy link
Contributor Author

cseelus commented May 2, 2021

I've added a custom class option for this helper.

Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks good.

Could you please add a simple test case to ensure the option generates the HTML you expect? Your change is simple and I'm sure it works, but we need the test to ensure that we don't break the behaviour in the future if, for example, we do some major refactoring or clean-up of the code.

We need to tell people about the new option in the README. There's a short section for errors_on. Just mention the option and perhaps give a quick example (maybe grab the test case).

Thanks again for taking the time to make this PR. We're almost there.

UPGRADE-5.0.md Show resolved Hide resolved
lib/bootstrap_form/helpers/bootstrap.rb Outdated Show resolved Hide resolved
UPGRADE-5.0.md Show resolved Hide resolved
@cseelus cseelus force-pushed the errors_on_invalid_feedback branch from fb87d7d to 4b9c5de Compare May 2, 2021 17:53
@cseelus
Copy link
Contributor Author

cseelus commented May 2, 2021

Now that the approach seems to be ok, I added tests and more info about this change to the docs and into the changelog.

Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I'll resolve the merge conflict and merge it. Thanks again for all your work on this.

@@ -803,7 +802,19 @@ You can hide the attribute name like this:
Which outputs:

```html
<div class="alert alert-danger">can't be blank.</div>
<div class="invalid-feedback">can't be blank.</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Clear and to the point. I like it.


This will display the error as any other [Bootstrap inline form error](https://getbootstrap.com/docs/5.0/forms/validation/#server-side), instead of displaying it as an [Bootstrap alert](https://getbootstrap.com/docs/5.0/components/alerts/).

You can use the `custom_class` options for this helper with `alert alert-danger` to restore the old behaviour:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again. Very clear.


assert_equivalent_xml expected, @builder.errors_on(:email, hide_attribute_name: true)
end

test "errors_on use custom CSS classes" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lcreid lcreid merged commit e3d03df into bootstrap-ruby:bootstrap-5 May 5, 2021
lcreid added a commit that referenced this pull request Nov 12, 2021
* Start README for Bootstrap 5

* Preliminary support for Bootstrap 5 (#567)

* Switch demo bootstrap JS include URL

* Remove "custom-control" support from radios and check boxes

In 5.0 they are consolidated into the .form-check class, and no longer
need to be treated as separate cases. Relevant tests will be fixed or
removed in the next commit.

* Remove "custom-control" tests for radios and check boxes

* Rename ".custom-file" to ".form-file"

* Change all ".form-group" uses to ".mb-3"

Bootstrap 5 is now recommending using bottom margin utilities to
control group spacing, and has removed ".form-group" entirely.

* Replace ".form-row" with gutter utils (".g-3")

Some methods in FormGroup were refactored to meet a RuboCop lint
complexity requirement. I don't personally think the refactor is
necessary but it won't pass CI without it.

* Replace ".form-inline" where necessary

Bootstrap 5 removes ".form-inline" in favor of the usage of ".col-auto"
and the new gutter utilities.

* Remove wrapper divs for elements prepended/appended to input groups

Bootstrap 5 removes ".input-group-prepend" and ".input-group-append",
they are no longer necessary. You can now add buttons and
".input-group-text" as direct children of the input groups.

* Add ".form-label" to all generated label tags

* Fix broken tests after label class change

* Fix switch style check boxes

My heavy-handedness with the previous commits removed the ability to use
switch style checkboxes when I removed the custom check box classes.

* Update switch checkbox syntax in README.md

* Add anchors for stricter #classes_include_gutters?

* Handle string or array of classes for check boxes and radio buttons

The Rails view helpers that accept a `class` option accept both single
strings and arrays of strings, so this change makes the CSS class array
builder agnostic to the input type.

I'm now also noticing that the result already had `#flatten` called on
it, so this probably wasn't an issue, but this is nicer!

* Use only form-check-label class for check box and radio button labels

Thanks to @thimo for catching this one.

* Change select box class from "form-control" to "form-select"

This required some extra effort because all the select forms inherited
their control class from the base input class.

* Add upgrade doc and update gemspec

* Remove role="form" (#571)

* Fix tests in bootstrap-5 branch. Fixes #582 (#583)

* Fix tests for Rails updates

* Fix Rubocop offenses

Dangerfile:48:3: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions.
  if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3
  ^^
Dangerfile:48:42: C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal
  if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3
                                         ^^
bootstrap_form.gemspec:27:3: W: Lint/ConstantDefinitionInBlock: Do not define constants this way within a block. (https://rubystyle.guide#no-constant-definition-in-block)
  REQUIRED_RAILS_VERSION = ">= 5.2".freeze
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
demo/config/puma.rb:7:21: C: [Correctable] Style/RedundantFetchBlock: Use fetch("RAILS_MAX_THREADS", 5) instead of fetch("RAILS_MAX_THREADS") { 5 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code)
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
demo/config/puma.rb:12:17: C: [Correctable] Style/RedundantFetchBlock: Use fetch("PORT", 3000) instead of fetch("PORT") { 3000 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code)
port        ENV.fetch("PORT") { 3000 }
                ^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form.rb:5:11: C: [Correctable] Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation)
  require Gem::Specification.find_by_name("actiontext").gem_dir + ...
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/components/validation.rb:17:22: C: [Correctable] Style/ClassEqualityComparison: Use instance_of?(Class) instead of comparing classes. (https://rubystyle.guide#instance-of-vs-class-comparison)
        target = obj.class == Class ? obj : obj.class
                     ^^^^^^^^^^^^^^
lib/bootstrap_form/form_builder.rb:48:5: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize.
    # rubocop:disable Metrics/AbcSize
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/form_group_builder.rb:24:9: C: [Correctable] Style/ExplicitBlockArgument: Consider using explicit block argument in the surrounding method's signature over yield. (https://rubystyle.guide#block-argument)
        form_group(method, form_group_options) { yield }
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/form_group_builder.rb:32:59: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer unless conditions.
        options[:required] = form_group_required(options) if options.key?(:skip_required)
                                                          ^^
lib/bootstrap_form/form_group_builder.rb:60:7: C: [Correctable] Style/RedundantAssignment: Redundant assignment before returning detected.
      hash = { ...
      ^^^^^^^^
lib/bootstrap_form/helpers/bootstrap.rb:25:44: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize.
      def alert_message(title, options={}) # rubocop:disable Metrics/AbcSize
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/test_helper.rb:7:18: C: [Correctable] Style/RedundantFileExtensionInRequire: Redundant .rb file extension detected. (https://rubystyle.guide#no-explicit-rb-to-require)
require_relative "../demo/config/environment.rb"

* Update CHANGELOG

* Add gemfile for Rails 6.1

* Run Travis against latest Ruby versions

* Update tests to both handle Rails 5.2/6 and Rails 6.1

* Step down 1 minor version for Ruby as Travis is not yet ready

* Update changelog

* Support Bootstrap 5 floating labels. Fixes #573 (#584)

* Support floating labels

* Add tests for floating labels

* Update demo app with floating labels section

* Add floating labels to CHANGELOG

* Describe floating labels in README

* Fix rubop offense for block length

lib/bootstrap_form/inputs/base.rb:8:7: C: Metrics/BlockLength: Block has too many lines. [26/25]
      class_methods do ...
      ^^^^^^^^^^^^^^^^

* Fix capitalization

* Use <<~ instead of strip_heredoc

* Simplify rendering of file_field for Bootstrap 5. Fixes #572 (#581)

* Use Bootstrap 5 beta 3 CDN libraries in demo app

Links to both CSS and JS libraries taken from https://getbootstrap.com/docs/5.0/getting-started/introduction/

* Remove linking ../images

Folder doesn’t exist and causes the error "ActionView::Template::Error (link_tree argument must be a directory)"

* Cleanup generated HTML for file upload  as per Bootstrap 5

See #572

* Update tests for new file upload rendering

* Add changelog entry

* Fix Rubocop offense on whitespace

lib/bootstrap_form/inputs/file_field.rb:10:52: C: [Correctable] Layout/SpaceAroundEqualsInParameterDefault: Surrounding space detected in default value assignment. (https://rubystyle.guide#spaces-around-equals)
        def file_field_with_bootstrap(name, options = {})
                                                   ^^^

Co-authored-by: Larry Reid <lcreid@jadesystems.ca>

* Get rid of `heredoc` on `bootstrap-5` branch (#591)

* Ignore RubyMine config directory

* Initial setup of GitHb Actions

* Run tests for rails 5 and rails 6

* Run tests for rails 5 and rails 6 + run lint job

* GH Actions: Correct gemfile names

* GH Actions: Only run the test task in the matrix.  rubocop is run in the separate Lint job.

* GH Actions: Separate the Danger run for better output

* GH Actions: Run rubocop directly instead of as a Rake task.  Allow autocorrectable offences.

* GH Actions: Only run Danger for pull requests

* GH Actions: Try to calm RuboCop

* Use the default Gemfile to pick up rubocop.yml

* GH Actions: Ignore the vendor directory for rubocop

* Forward the options as keyword arguments

* Test Rails 6.1 and skip Rails 5.2 + Ruby 3.0

* Fix Rails 6.1 tests on master (#586)

* Fix tests for Rails 6.1

* Fix Rubocop offenses

bootstrap_form.gemspec:27:29: C: Gemspec/RequiredRubyVersion: required_ruby_version (2.5, declared in bootstrap_form.gemspec) and TargetRubyVersion (2.7, which may be specified in .rubocop.yml) should be equal.
  s.required_ruby_version = ">= 2.5"
                            ^^^^^^^^
lib/bootstrap_form/form_group.rb:14:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent)
                             :input_group_class, :label_col, :control_col,
                             ^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/form_group.rb:15:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent)
                             :add_control_col_class, :layout, :prepend)) do
                             ^^^^^^^^^^^^^^^^^^^^^^
test/bootstrap_form_test.rb:123:103: C: [Correctable] Style/IfUnlessModifier: Modifier form of if makes the line too long. (https://rubystyle.guide#if-as-a-modifier)
        <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}>
                                                                                                      ^^
test/bootstrap_form_test.rb:123:133: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
        <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}>
                                                                                                                                    ^^^^^
test/bootstrap_rich_text_area_test.rb:23:54: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
      "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename"
                                                     ^^^^^^^^^^^
test/bootstrap_rich_text_area_test.rb:23:97: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
      "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename"
                                                                                                ^^^^^

* Include Rails 6.1 in Travis tests + update Ruby versions

* Update CHANGELOG

* Rails Edge requires Ruby 2.7+

* Remove rubocop_todo and fix Rubocop offenses

* Replace strip_heredoc with <<~ (#587)

* Replace strip_heredoc with <<~

Also fix newly detected Rubocop offenses on indentation

* Update CHANGELOG

* Simplify Dockerfile and add documentation (#588)

* Simplify Dockerfile and add documentation

* A few more additions to .gitignore

* Ignore gems placed when using Dockerfile (#590)

* Fix formatting and heredoc

* Fix bad merge

Co-authored-by: Uwe Kubosch <uwe@kubosch.no>
Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com>
Co-authored-by: Thimo Jansen <thimo@defrog.nl>

* Cherry pick some commits from `main` (#594)

* Change default branch to `main` (#592)

* Change default branch to `main`

* Add GitHub token for Danger

* Change default branch to `main` (#592)

* Change default branch to `main`

* Add GitHub token for Danger

* Fix deprecation that I broke again

* Errors on invalid feedback (#580)

* Use "invalid-feedback" class name for errors_on

* Add custom class option for errors_on helper

* Improve tests, docs and changelog

Co-authored-by: Larry Reid <lcreid@jadesystems.ca>

* README: Use GH Actions badge, drop Travis badge, configuration file (#600)

* README: Use GH Actions badge, drop Travis badge

* Delete unused TravisCI configuration file

* Update README for release of 5.0

Co-authored-by: Taylor Thurlow <taylorthurlow@me.com>
Co-authored-by: Thimo Jansen <thimo@defrog.nl>
Co-authored-by: Uwe Kubosch <uwe@kubosch.no>
Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com>
Co-authored-by: Chrıs Seelus <cseelus@gmail.com>
Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
lcreid added a commit that referenced this pull request Nov 12, 2021
* Start README for Bootstrap 5

* Preliminary support for Bootstrap 5 (#567)

* Switch demo bootstrap JS include URL

* Remove "custom-control" support from radios and check boxes

In 5.0 they are consolidated into the .form-check class, and no longer
need to be treated as separate cases. Relevant tests will be fixed or
removed in the next commit.

* Remove "custom-control" tests for radios and check boxes

* Rename ".custom-file" to ".form-file"

* Change all ".form-group" uses to ".mb-3"

Bootstrap 5 is now recommending using bottom margin utilities to
control group spacing, and has removed ".form-group" entirely.

* Replace ".form-row" with gutter utils (".g-3")

Some methods in FormGroup were refactored to meet a RuboCop lint
complexity requirement. I don't personally think the refactor is
necessary but it won't pass CI without it.

* Replace ".form-inline" where necessary

Bootstrap 5 removes ".form-inline" in favor of the usage of ".col-auto"
and the new gutter utilities.

* Remove wrapper divs for elements prepended/appended to input groups

Bootstrap 5 removes ".input-group-prepend" and ".input-group-append",
they are no longer necessary. You can now add buttons and
".input-group-text" as direct children of the input groups.

* Add ".form-label" to all generated label tags

* Fix broken tests after label class change

* Fix switch style check boxes

My heavy-handedness with the previous commits removed the ability to use
switch style checkboxes when I removed the custom check box classes.

* Update switch checkbox syntax in README.md

* Add anchors for stricter #classes_include_gutters?

* Handle string or array of classes for check boxes and radio buttons

The Rails view helpers that accept a `class` option accept both single
strings and arrays of strings, so this change makes the CSS class array
builder agnostic to the input type.

I'm now also noticing that the result already had `#flatten` called on
it, so this probably wasn't an issue, but this is nicer!

* Use only form-check-label class for check box and radio button labels

Thanks to @thimo for catching this one.

* Change select box class from "form-control" to "form-select"

This required some extra effort because all the select forms inherited
their control class from the base input class.

* Add upgrade doc and update gemspec

* Remove role="form" (#571)

* Fix tests in bootstrap-5 branch. Fixes #582 (#583)

* Fix tests for Rails updates

* Fix Rubocop offenses

Dangerfile:48:3: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions.
  if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3
  ^^
Dangerfile:48:42: C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal
  if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3
                                         ^^
bootstrap_form.gemspec:27:3: W: Lint/ConstantDefinitionInBlock: Do not define constants this way within a block. (https://rubystyle.guide#no-constant-definition-in-block)
  REQUIRED_RAILS_VERSION = ">= 5.2".freeze
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
demo/config/puma.rb:7:21: C: [Correctable] Style/RedundantFetchBlock: Use fetch("RAILS_MAX_THREADS", 5) instead of fetch("RAILS_MAX_THREADS") { 5 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code)
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
demo/config/puma.rb:12:17: C: [Correctable] Style/RedundantFetchBlock: Use fetch("PORT", 3000) instead of fetch("PORT") { 3000 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code)
port        ENV.fetch("PORT") { 3000 }
                ^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form.rb:5:11: C: [Correctable] Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation)
  require Gem::Specification.find_by_name("actiontext").gem_dir + ...
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/components/validation.rb:17:22: C: [Correctable] Style/ClassEqualityComparison: Use instance_of?(Class) instead of comparing classes. (https://rubystyle.guide#instance-of-vs-class-comparison)
        target = obj.class == Class ? obj : obj.class
                     ^^^^^^^^^^^^^^
lib/bootstrap_form/form_builder.rb:48:5: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize.
    # rubocop:disable Metrics/AbcSize
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/form_group_builder.rb:24:9: C: [Correctable] Style/ExplicitBlockArgument: Consider using explicit block argument in the surrounding method's signature over yield. (https://rubystyle.guide#block-argument)
        form_group(method, form_group_options) { yield }
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/form_group_builder.rb:32:59: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer unless conditions.
        options[:required] = form_group_required(options) if options.key?(:skip_required)
                                                          ^^
lib/bootstrap_form/form_group_builder.rb:60:7: C: [Correctable] Style/RedundantAssignment: Redundant assignment before returning detected.
      hash = { ...
      ^^^^^^^^
lib/bootstrap_form/helpers/bootstrap.rb:25:44: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize.
      def alert_message(title, options={}) # rubocop:disable Metrics/AbcSize
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/test_helper.rb:7:18: C: [Correctable] Style/RedundantFileExtensionInRequire: Redundant .rb file extension detected. (https://rubystyle.guide#no-explicit-rb-to-require)
require_relative "../demo/config/environment.rb"

* Update CHANGELOG

* Add gemfile for Rails 6.1

* Run Travis against latest Ruby versions

* Update tests to both handle Rails 5.2/6 and Rails 6.1

* Step down 1 minor version for Ruby as Travis is not yet ready

* Update changelog

* Support Bootstrap 5 floating labels. Fixes #573 (#584)

* Support floating labels

* Add tests for floating labels

* Update demo app with floating labels section

* Add floating labels to CHANGELOG

* Describe floating labels in README

* Fix rubop offense for block length

lib/bootstrap_form/inputs/base.rb:8:7: C: Metrics/BlockLength: Block has too many lines. [26/25]
      class_methods do ...
      ^^^^^^^^^^^^^^^^

* Fix capitalization

* Use <<~ instead of strip_heredoc

* Simplify rendering of file_field for Bootstrap 5. Fixes #572 (#581)

* Use Bootstrap 5 beta 3 CDN libraries in demo app

Links to both CSS and JS libraries taken from https://getbootstrap.com/docs/5.0/getting-started/introduction/

* Remove linking ../images

Folder doesn’t exist and causes the error "ActionView::Template::Error (link_tree argument must be a directory)"

* Cleanup generated HTML for file upload  as per Bootstrap 5

See #572

* Update tests for new file upload rendering

* Add changelog entry

* Fix Rubocop offense on whitespace

lib/bootstrap_form/inputs/file_field.rb:10:52: C: [Correctable] Layout/SpaceAroundEqualsInParameterDefault: Surrounding space detected in default value assignment. (https://rubystyle.guide#spaces-around-equals)
        def file_field_with_bootstrap(name, options = {})
                                                   ^^^

Co-authored-by: Larry Reid <lcreid@jadesystems.ca>

* Get rid of `heredoc` on `bootstrap-5` branch (#591)

* Ignore RubyMine config directory

* Initial setup of GitHb Actions

* Run tests for rails 5 and rails 6

* Run tests for rails 5 and rails 6 + run lint job

* GH Actions: Correct gemfile names

* GH Actions: Only run the test task in the matrix.  rubocop is run in the separate Lint job.

* GH Actions: Separate the Danger run for better output

* GH Actions: Run rubocop directly instead of as a Rake task.  Allow autocorrectable offences.

* GH Actions: Only run Danger for pull requests

* GH Actions: Try to calm RuboCop

* Use the default Gemfile to pick up rubocop.yml

* GH Actions: Ignore the vendor directory for rubocop

* Forward the options as keyword arguments

* Test Rails 6.1 and skip Rails 5.2 + Ruby 3.0

* Fix Rails 6.1 tests on master (#586)

* Fix tests for Rails 6.1

* Fix Rubocop offenses

bootstrap_form.gemspec:27:29: C: Gemspec/RequiredRubyVersion: required_ruby_version (2.5, declared in bootstrap_form.gemspec) and TargetRubyVersion (2.7, which may be specified in .rubocop.yml) should be equal.
  s.required_ruby_version = ">= 2.5"
                            ^^^^^^^^
lib/bootstrap_form/form_group.rb:14:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent)
                             :input_group_class, :label_col, :control_col,
                             ^^^^^^^^^^^^^^^^^^
lib/bootstrap_form/form_group.rb:15:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent)
                             :add_control_col_class, :layout, :prepend)) do
                             ^^^^^^^^^^^^^^^^^^^^^^
test/bootstrap_form_test.rb:123:103: C: [Correctable] Style/IfUnlessModifier: Modifier form of if makes the line too long. (https://rubystyle.guide#if-as-a-modifier)
        <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}>
                                                                                                      ^^
test/bootstrap_form_test.rb:123:133: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
        <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}>
                                                                                                                                    ^^^^^
test/bootstrap_rich_text_area_test.rb:23:54: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
      "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename"
                                                     ^^^^^^^^^^^
test/bootstrap_rich_text_area_test.rb:23:97: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
      "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename"
                                                                                                ^^^^^

* Include Rails 6.1 in Travis tests + update Ruby versions

* Update CHANGELOG

* Rails Edge requires Ruby 2.7+

* Remove rubocop_todo and fix Rubocop offenses

* Replace strip_heredoc with <<~ (#587)

* Replace strip_heredoc with <<~

Also fix newly detected Rubocop offenses on indentation

* Update CHANGELOG

* Simplify Dockerfile and add documentation (#588)

* Simplify Dockerfile and add documentation

* A few more additions to .gitignore

* Ignore gems placed when using Dockerfile (#590)

* Fix formatting and heredoc

* Fix bad merge

Co-authored-by: Uwe Kubosch <uwe@kubosch.no>
Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com>
Co-authored-by: Thimo Jansen <thimo@defrog.nl>

* Cherry pick some commits from `main` (#594)

* Change default branch to `main` (#592)

* Change default branch to `main`

* Add GitHub token for Danger

* Change default branch to `main` (#592)

* Change default branch to `main`

* Add GitHub token for Danger

* Fix deprecation that I broke again

* Errors on invalid feedback (#580)

* Use "invalid-feedback" class name for errors_on

* Add custom class option for errors_on helper

* Improve tests, docs and changelog

Co-authored-by: Larry Reid <lcreid@jadesystems.ca>

* README: Use GH Actions badge, drop Travis badge, configuration file (#600)

* README: Use GH Actions badge, drop Travis badge

* Delete unused TravisCI configuration file

* Update README for release of 5.0

* Preparing v5.0.0

Co-authored-by: Taylor Thurlow <taylorthurlow@me.com>
Co-authored-by: Thimo Jansen <thimo@defrog.nl>
Co-authored-by: Uwe Kubosch <uwe@kubosch.no>
Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com>
Co-authored-by: Chrıs Seelus <cseelus@gmail.com>
Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
CharlieWinkwaves pushed a commit to CharlieWinkwaves/bootstrap_form that referenced this pull request Dec 28, 2021
* Use "invalid-feedback" class name for errors_on

* Add custom class option for errors_on helper

* Improve tests, docs and changelog

Co-authored-by: Larry Reid <lcreid@jadesystems.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants