-
Notifications
You must be signed in to change notification settings - Fork 354
[WIP] Bootstrap v4 #315
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
Merged
Merged
[WIP] Bootstrap v4 #315
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
740d188
has-error is now has-danger
desheikh eb99702
inputs with errors should have form-control-feedback
desheikh 604b460
control-label is now form-control-label
desheikh eba51ac
btn-default is now btn-secondary
desheikh 889112c
form-horizontal is no longer a required class
desheikh 7853ee5
input field should have form-control-danger on error
desheikh 8317d9f
checkbox is now form-check
desheikh 90d219d
checkbox input should have form-check-input
desheikh 0210000
non inline checkbox labels should have form-check-label
desheikh a68a242
Support :prepend and :append for the `select` helper (#327)
donv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,7 @@ def time_zone_select_with_bootstrap(method, priority_zones = nil, options = {}, | |
| def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_value = "0", &block) | ||
| options = options.symbolize_keys! | ||
| check_box_options = options.except(:label, :label_class, :help, :inline) | ||
| check_box_options[:class] = ["form-check-input", check_box_options[:class]].compact.join(' ') | ||
|
|
||
| html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value) | ||
| label_content = block_given? ? capture(&block) : options[:label] | ||
|
|
@@ -134,10 +135,10 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_ | |
|
|
||
| if options[:inline] | ||
| label_class = " #{label_class}" if label_class | ||
| label(label_name, html, class: "checkbox-inline#{disabled_class}#{label_class}") | ||
| label(label_name, html, class: "form-check-inline#{disabled_class}#{label_class}") | ||
| else | ||
| content_tag(:div, class: "checkbox#{disabled_class}") do | ||
| label(label_name, html, class: label_class) | ||
| content_tag(:div, class: "form-check#{disabled_class}") do | ||
| label(label_name, html, class: ["form-check-label", label_class].compact.join(" ")) | ||
| end | ||
| end | ||
| end | ||
|
|
@@ -198,6 +199,7 @@ def form_group(*args, &block) | |
| name = args.first | ||
|
|
||
| options[:class] = ["form-group", options[:class]].compact.join(' ') | ||
| options[:class] << " row" if get_group_layout(options[:layout]) == :horizontal | ||
| options[:class] << " #{error_class}" if has_error?(name) | ||
| options[:class] << " #{feedback_class}" if options[:icon] | ||
|
|
||
|
|
@@ -263,11 +265,11 @@ def control_class | |
| end | ||
|
|
||
| def label_class | ||
| "control-label" | ||
| "form-control-label" | ||
| end | ||
|
|
||
| def error_class | ||
| "has-error" | ||
| "has-danger" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Fix this class. I think we want |
||
| end | ||
|
|
||
| def feedback_class | ||
|
|
@@ -313,6 +315,7 @@ def form_group_builder(method, options, html_options = nil) | |
| css_options = html_options || options | ||
| control_classes = css_options.delete(:control_class) { control_class } | ||
| css_options[:class] = [control_classes, css_options[:class]].compact.join(" ") | ||
| css_options[:class] << " form-control-danger" if has_error?(method) | ||
|
|
||
| options = convert_form_tag_options(method, options) if acts_like_form_tag | ||
|
|
||
|
|
@@ -389,12 +392,16 @@ def generate_label(id, name, options, custom_label_col, group_layout) | |
| end | ||
|
|
||
| def generate_help(name, help_text) | ||
| help_text = get_error_messages(name) if has_error?(name) && inline_errors | ||
| return if help_text === false | ||
| if has_error?(name) && inline_errors | ||
| help_text = get_error_messages(name) | ||
| help_klass = 'form-control-feedback' | ||
| end | ||
| return if help_text == false | ||
|
|
||
| help_klass ||= 'form-text text-muted' | ||
| help_text ||= get_help_text_by_i18n_key(name) | ||
|
|
||
| content_tag(:span, help_text, class: 'help-block') if help_text.present? | ||
| content_tag(:span, help_text, class: help_klass) if help_text.present? | ||
| end | ||
|
|
||
| def generate_icon(icon) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @GBH pointed out,
has-dangerisn't in Bootstrap 4 anymore. We should either fix the PR, or merge and remember to fix. Whatever is easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for merge and fix later or this is going to be sitting here for weeks.