Skip to content

Commit c7590c2

Browse files
author
Nikolay Moskvin
committed
Fixed fields render for form tag
1 parent ec20b97 commit c7590c2

File tree

7 files changed

+25
-23
lines changed

7 files changed

+25
-23
lines changed

app/assets/javascripts/rails_admin/ra.filtering-multiselect.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
this.header = $('<div class="ra-multiselect-header ui-helper-clearfix">');
5050

51-
this.filter = $('<input type="search" placeholder="' + this.options.regional.search + '" class="ra-multiselect-search"/>');
51+
this.filter = $('<input type="search" placeholder="' + this.options.regional.search + '" class="form-control ra-multiselect-search"/>');
5252

5353
this.header.append(this.filter);
5454

@@ -68,7 +68,7 @@
6868

6969
this.collection = $('<select multiple="multiple"></select>');
7070

71-
this.collection.addClass("ra-multiselect-collection");
71+
this.collection.addClass("form-control ra-multiselect-collection");
7272

7373
this.addAll = $('<a href="#" class="ra-multiselect-item-add-all"><span class="ui-icon ui-icon-circle-triangle-e"></span>' + this.options.regional.chooseAll + '</a>');
7474

@@ -89,7 +89,7 @@
8989
this.columns.center.append(this.up).append(this.down);
9090
}
9191

92-
this.selection = $('<select class="ra-multiselect-selection" multiple="multiple"></select>');
92+
this.selection = $('<select class="form-control ra-multiselect-selection" multiple="multiple"></select>');
9393

9494

9595

app/assets/javascripts/rails_admin/ra.filtering-select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
var filtering_select = $('<div class="input-append filtering-select" style="float:left"></div>')
4343
var input = this.input = $('<input type="text">')
4444
.val(value)
45-
.addClass("ra-filtering-select-input")
45+
.addClass("form-control ra-filtering-select-input")
4646
.attr('style', select.attr('style'))
4747
.show()
4848
.autocomplete({

app/assets/stylesheets/rails_admin/base/theming.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ body.rails_admin {
6060
line-height: 16px;
6161
}
6262
.help-block {
63-
margin-top: 0px;
63+
// margin-top: 0px;
6464
}
6565
.input-prepend, .input-append {
6666
margin-bottom: 0px;
@@ -73,7 +73,7 @@ body.rails_admin {
7373
padding-top:15px;
7474
}
7575
.control-label {
76-
width:145px;
76+
// width:145px;
7777
}
7878
legend {
7979
margin-bottom:0px;

app/helpers/rails_admin/form_builder.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def field_wrapper_for(field, nested_in)
3535
# do not show nested field if the target is the origin
3636
unless nested_field_association?(field, nested_in)
3737
@template.content_tag(:div, class: "control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do
38-
label(field.method_name, capitalize_first_letter(field.label), class: 'control-label') + (field.nested_form ? field_for(field) : input_for(field))
38+
label(field.method_name, capitalize_first_letter(field.label), class: 'col-sm-2 control-label') +
39+
(field.nested_form ? field_for(field) : input_for(field))
3940
end
4041
end
4142
else
@@ -44,7 +45,7 @@ def field_wrapper_for(field, nested_in)
4445
end
4546

4647
def input_for(field)
47-
@template.content_tag(:div, class: 'controls') do
48+
@template.content_tag(:div, class: 'col-sm-10 controls') do
4849
field_for(field) +
4950
errors_for(field) +
5051
help_for(field)
@@ -56,7 +57,7 @@ def errors_for(field)
5657
end
5758

5859
def help_for(field)
59-
field.help.present? ? @template.content_tag(:p, field.help, class: 'help-block') : ''.html_safe
60+
field.help.present? ? @template.content_tag(:span, field.help, class: 'help-block') : ''.html_safe
6061
end
6162

6263
def field_for(field)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, checked: field.form_value.in?([true, '1'])})
1+
= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, checked: field.form_value.in?([true, '1']), class: 'form-control'})
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: false, options: {}.to_json }).reverse_merge({ value: field.form_value })
1+
= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: false, options: {}.to_json }).reverse_merge({ value: field.form_value, class: 'form-control' })

app/views/rails_admin/main/export.html.haml

+13-12
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
%fieldset{id: 'fields_to_export'}
88
%div.control-group
99
%div.controls
10-
%label.checkbox{for: 'check_all'}
11-
= t('admin.export.select_all_fields')
10+
.col-sm-2
11+
%label.col-sm-10.checkbox{for: 'check_all'}
1212
= check_box_tag 'all', 'all', true, { id: 'check_all' }
13+
= t('admin.export.select_all_fields')
1314
%legend
1415
%i.icon-chevron-down
1516
= t('admin.export.select')
1617
.control-group
17-
%label.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from', name: @model_config.label_plural.downcase)
18-
.controls
18+
%label.col-sm-2.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from', name: @model_config.label_plural.downcase)
19+
.col-sm-10.controls
1920
- visible_fields.select{ |f| !f.association? || f.association.polymorphic? }.each do |field|
2021
- list = field.virtual? ? 'methods' : 'only'
2122
- if field.association? && field.association.polymorphic?
@@ -34,8 +35,8 @@
3435
- visible_fields.select{ |f| f.association? && !f.association.polymorphic? }.each do |field|
3536
- fields = field.associated_model_config.export.with(controller: self.controller, view: self, object: (associated_model = field.associated_model_config.abstract_model.model).new).visible_fields.select{ |f| !f.association? }
3637
.control-group
37-
%label.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from_associated', name: field.label.downcase)
38-
.controls
38+
%label.col-sm-2.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from_associated', name: field.label.downcase)
39+
.col-sm-10.controls
3940
- fields.each do |associated_model_field|
4041
- list = associated_model_field.virtual? ? 'methods' : 'only'
4142
%label.checkbox{for: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}"}
@@ -48,21 +49,21 @@
4849
= t('admin.export.options_for', name: 'csv')
4950
.control-group
5051
- guessed_encoding = @abstract_model.encoding
51-
%label.control-label{for: "csv_options_encoding_to"}= t('admin.export.csv.encoding_to')
52-
.controls
52+
%label.col-sm-2.control-label{for: "csv_options_encoding_to"}= t('admin.export.csv.encoding_to')
53+
.col-sm-10.controls
5354
-# from http://books.google.com/support/partner/bin/answer.py?answer=30990 :
5455
= select_tag 'csv_options[encoding_to]', options_for_select(RailsAdmin::CSVConverter::TARGET_ENCODINGS), include_blank: true
5556
%p.help-block= t('admin.export.csv.encoding_to_help', name: guessed_encoding)
5657

5758
.control-group
58-
%label.control-label{for: "csv_options_skip_header"}= t('admin.export.csv.skip_header')
59-
.controls
59+
%label.col-sm-2.control-label{for: "csv_options_skip_header"}= t('admin.export.csv.skip_header')
60+
.col-sm-10.controls
6061
= check_box_tag 'csv_options[skip_header]', 'true'
6162
%p.help-block= t('admin.export.csv.skip_header_help')
6263

6364
.control-group
64-
%label.control-label{for: "csv_options_generator_col_sep"}= t('admin.export.csv.col_sep')
65-
.controls
65+
%label.col-sm-2.control-label{for: "csv_options_generator_col_sep"}= t('admin.export.csv.col_sep')
66+
.col-sm-10.controls
6667
= select_tag 'csv_options[generator][col_sep]', options_for_select({ '' => t('admin.export.csv.default_col_sep'), "<comma> ','" => ',', "<semicolon> ';'" => ';', '<tabs>' => "'\t'" })
6768
%p.help-block= t('admin.export.csv.col_sep_help', value: t('admin.export.csv.default_col_sep'))
6869

0 commit comments

Comments
 (0)