diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index b4b44b238a..a1c04b08f3 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -194,4 +194,13 @@ module CustomFieldsHelper end form.select :edit_tag_style, select_options, :label => :label_display end + + def select_type_radio_buttons(default_type) + default_type = 'IssueCustomField' if CUSTOM_FIELDS_TABS.none?{|tab| tab[:name] == default_type} + custom_field_type_options.map do |name, type| + content_tag(:label, :style => 'display:block;') do + radio_button_tag('type', type, type == default_type) + name + end + end.join("\n").html_safe + end end diff --git a/app/views/custom_fields/index.html.erb b/app/views/custom_fields/index.html.erb index cf2193db52..3f1154dc7d 100644 --- a/app/views/custom_fields/index.html.erb +++ b/app/views/custom_fields/index.html.erb @@ -1,5 +1,5 @@
-<%= link_to l(:label_custom_field_new), new_custom_field_path, :class => 'icon icon-add' %> +<%= link_to_function l(:label_custom_field_new), "location.href = '#{new_custom_field_path}?tab=' + encodeURIComponent($('.tabs a.selected').attr('id').split('tab-').pop())", :class => 'icon icon-add' %>
<%= title l(:label_custom_field_plural) %> diff --git a/app/views/custom_fields/select_type.html.erb b/app/views/custom_fields/select_type.html.erb index 084c9f3a76..78d3e940ed 100644 --- a/app/views/custom_fields/select_type.html.erb +++ b/app/views/custom_fields/select_type.html.erb @@ -1,13 +1,10 @@ <%= custom_field_title @custom_field %> -<% selected = 0 %> <%= form_tag new_custom_field_path, :method => 'get' do %>

<%= l(:label_custom_field_select_type) %>:

- <% custom_field_type_options.each do |name, type| %> - - <% end %> + <%= select_type_radio_buttons(params[:tab]) %>

<%= submit_tag l(:label_next).html_safe + " »".html_safe, :name => nil %>

diff --git a/test/helpers/custom_fields_helper_test.rb b/test/helpers/custom_fields_helper_test.rb index 0316921128..9bbdcd8e6a 100644 --- a/test/helpers/custom_fields_helper_test.rb +++ b/test/helpers/custom_fields_helper_test.rb @@ -95,4 +95,14 @@ class CustomFieldsHelperTest < Redmine::HelperTest assert_select_in custom_field_tag('object', value), 'textarea[class=?]', 'text_cf wiki-edit' end + + def test_select_type_radio_buttons + result = select_type_radio_buttons('UserCustomField') + assert_select_in result, 'input[type="radio"]', :count => 10 + assert_select_in result, 'input#type_UserCustomField[checked=?]', 'checked' + + result = select_type_radio_buttons(nil) + assert_select_in result, 'input[type="radio"]', :count => 10 + assert_select_in result, 'input#type_IssueCustomField[checked=?]', 'checked' + end end