Adds css class to custom field input tags.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9608 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-05-01 16:50:42 +00:00
parent bebe429472
commit c085367bb6
3 changed files with 19 additions and 13 deletions

View File

@ -39,15 +39,17 @@ module CustomFieldsHelper
field_name << "[]" if custom_field.multiple? field_name << "[]" if custom_field.multiple?
field_id = "#{name}_custom_field_values_#{custom_field.id}" field_id = "#{name}_custom_field_values_#{custom_field.id}"
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as) case field_format.try(:edit_as)
when "date" when "date"
text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) + text_field_tag(field_name, custom_value.value, tag_options.merge(:size => 10)) +
calendar_for(field_id) calendar_for(field_id)
when "text" when "text"
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%') text_area_tag(field_name, custom_value.value, tag_options.merge(:rows => 3))
when "bool" when "bool"
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, :id => field_id) hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, tag_options)
when "list" when "list"
blank_option = '' blank_option = ''
unless custom_field.multiple? unless custom_field.multiple?
@ -60,13 +62,13 @@ module CustomFieldsHelper
end end
end end
s = select_tag(field_name, blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), s = select_tag(field_name, blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value),
:id => field_id, :multiple => custom_field.multiple?) tag_options.merge(:multiple => custom_field.multiple?))
if custom_field.multiple? if custom_field.multiple?
s << hidden_field_tag(field_name, '') s << hidden_field_tag(field_name, '')
end end
s s
else else
text_field_tag(field_name, custom_value.value, :id => field_id) text_field_tag(field_name, custom_value.value, tag_options)
end end
end end
@ -86,26 +88,28 @@ module CustomFieldsHelper
field_name = "#{name}[custom_field_values][#{custom_field.id}]" field_name = "#{name}[custom_field_values][#{custom_field.id}]"
field_name << "[]" if custom_field.multiple? field_name << "[]" if custom_field.multiple?
field_id = "#{name}_custom_field_values_#{custom_field.id}" field_id = "#{name}_custom_field_values_#{custom_field.id}"
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as) case field_format.try(:edit_as)
when "date" when "date"
text_field_tag(field_name, '', :id => field_id, :size => 10) + text_field_tag(field_name, '', tag_options.merge(:size => 10)) +
calendar_for(field_id) calendar_for(field_id)
when "text" when "text"
text_area_tag(field_name, '', :id => field_id, :rows => 3, :style => 'width:90%') text_area_tag(field_name, '', tag_options.merge(:rows => 3))
when "bool" when "bool"
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''], select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
[l(:general_text_yes), '1'], [l(:general_text_yes), '1'],
[l(:general_text_no), '0']]), :id => field_id) [l(:general_text_no), '0']]), tag_options)
when "list" when "list"
options = [] options = []
options << [l(:label_no_change_option), ''] unless custom_field.multiple? options << [l(:label_no_change_option), ''] unless custom_field.multiple?
options << [l(:label_none), '__none__'] unless custom_field.is_required? options << [l(:label_none), '__none__'] unless custom_field.is_required?
options += custom_field.possible_values_options(projects) options += custom_field.possible_values_options(projects)
select_tag(field_name, options_for_select(options), select_tag(field_name, options_for_select(options), tag_options.merge(:multiple => custom_field.multiple?))
:id => field_id, :multiple => custom_field.multiple?)
else else
text_field_tag(field_name, '', :id => field_id) text_field_tag(field_name, '', tag_options)
end end
end end

View File

@ -521,6 +521,8 @@ a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px
em.info {font-style:normal;font-size:90%;color:#888;display:block;} em.info {font-style:normal;font-size:90%;color:#888;display:block;}
em.info.error {padding-left:20px; background:url(../images/exclamation.png) no-repeat 0 50%;} em.info.error {padding-left:20px; background:url(../images/exclamation.png) no-repeat 0 50%;}
textarea.text_cf {width:90%;}
/* Project members tab */ /* Project members tab */
div#tab-content-members .splitcontentleft, div#tab-content-memberships .splitcontentleft, div#tab-content-users .splitcontentleft { width: 64% } div#tab-content-members .splitcontentleft, div#tab-content-memberships .splitcontentleft, div#tab-content-users .splitcontentleft { width: 64% }
div#tab-content-members .splitcontentright, div#tab-content-memberships .splitcontentright, div#tab-content-users .splitcontentright { width: 34% } div#tab-content-members .splitcontentright, div#tab-content-memberships .splitcontentright, div#tab-content-users .splitcontentright { width: 34% }

View File

@ -1268,7 +1268,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_template 'new' assert_template 'new'
assert_tag 'select', assert_tag 'select',
:attributes => {:name => 'issue[custom_field_values][1]'}, :attributes => {:name => 'issue[custom_field_values][1]', :class => 'list_cf'},
:children => {:count => 4}, :children => {:count => 4},
:child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'} :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
end end
@ -2740,7 +2740,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_template 'bulk_edit' assert_template 'bulk_edit'
assert_tag :select, assert_tag :select,
:attributes => {:name => "issue[custom_field_values][#{field.id}]"}, :attributes => {:name => "issue[custom_field_values][#{field.id}]", :class => 'user_cf'},
:children => { :children => {
:only => {:tag => 'option'}, :only => {:tag => 'option'},
:count => Project.find(1).users.count + 2 # "no change" + "none" options :count => Project.find(1).users.count + 2 # "no change" + "none" options