From: Jean-Philippe Lang Date: Tue, 1 May 2012 16:50:42 +0000 (+0000) Subject: Adds css class to custom field input tags. X-Git-Tag: 2.0.0~74 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c085367bb63b8e6c6a6143265358374dc395365b;p=redmine.git 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 --- diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 5e63a5634..789d527b5 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -39,15 +39,17 @@ module CustomFieldsHelper field_name << "[]" if custom_field.multiple? 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) case field_format.try(:edit_as) 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) 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" - 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" blank_option = '' unless custom_field.multiple? @@ -60,13 +62,13 @@ module CustomFieldsHelper 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), - :id => field_id, :multiple => custom_field.multiple?) + tag_options.merge(:multiple => custom_field.multiple?)) if custom_field.multiple? s << hidden_field_tag(field_name, '') end s else - text_field_tag(field_name, custom_value.value, :id => field_id) + text_field_tag(field_name, custom_value.value, tag_options) end end @@ -86,26 +88,28 @@ module CustomFieldsHelper field_name = "#{name}[custom_field_values][#{custom_field.id}]" field_name << "[]" if custom_field.multiple? 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) case field_format.try(:edit_as) 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) 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" select_tag(field_name, options_for_select([[l(:label_no_change_option), ''], [l(:general_text_yes), '1'], - [l(:general_text_no), '0']]), :id => field_id) + [l(:general_text_no), '0']]), tag_options) when "list" options = [] options << [l(:label_no_change_option), ''] unless custom_field.multiple? options << [l(:label_none), '__none__'] unless custom_field.is_required? options += custom_field.possible_values_options(projects) - select_tag(field_name, options_for_select(options), - :id => field_id, :multiple => custom_field.multiple?) + select_tag(field_name, options_for_select(options), tag_options.merge(:multiple => custom_field.multiple?)) else - text_field_tag(field_name, '', :id => field_id) + text_field_tag(field_name, '', tag_options) end end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 48e56ca38..03fb2960a 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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.error {padding-left:20px; background:url(../images/exclamation.png) no-repeat 0 50%;} +textarea.text_cf {width:90%;} + /* Project members tab */ 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% } diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index bf24ff368..d719137f1 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1268,7 +1268,7 @@ class IssuesControllerTest < ActionController::TestCase assert_template 'new' assert_tag 'select', - :attributes => {:name => 'issue[custom_field_values][1]'}, + :attributes => {:name => 'issue[custom_field_values][1]', :class => 'list_cf'}, :children => {:count => 4}, :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'} end @@ -2740,7 +2740,7 @@ class IssuesControllerTest < ActionController::TestCase assert_template 'bulk_edit' assert_tag :select, - :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, + :attributes => {:name => "issue[custom_field_values][#{field.id}]", :class => 'user_cf'}, :children => { :only => {:tag => 'option'}, :count => Project.find(1).users.count + 2 # "no change" + "none" options