Project

General

Profile

Patch #31320 » change-default-value.patch

Mizuki ISHIKAWA, 2019-05-08 09:10

View differences:

app/helpers/custom_fields_helper.rb
194 194
    end
195 195
    form.select :edit_tag_style, select_options, :label => :label_display
196 196
  end
197

  
198
  def select_type_radio_buttons(default_type)
199
    default_type = 'IssueCustomField' if CUSTOM_FIELDS_TABS.none?{|tab| tab[:name] == default_type}
200
    custom_field_type_options.map do |name, type|
201
      content_tag(:label, :style => 'display:block;') do
202
        radio_button_tag('type', type, type == default_type) + name
203
      end
204
    end.join("\n").html_safe
205
  end
197 206
end
app/views/custom_fields/index.html.erb
1 1
<div class="contextual">
2
<%= link_to l(:label_custom_field_new), new_custom_field_path, :class => 'icon icon-add' %>
2
<%= 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' %>
3 3
</div>
4 4

  
5 5
<%= title l(:label_custom_field_plural) %>
app/views/custom_fields/select_type.html.erb
1 1
<%= custom_field_title @custom_field %>
2 2

  
3
<% selected = 0 %>
4 3
<%= form_tag new_custom_field_path, :method => 'get' do %>
5 4
  <div class="box">
6 5
  <p><%= l(:label_custom_field_select_type) %>:</p>
7 6
  <p>
8
  <% custom_field_type_options.each do |name, type| %>
9
    <label style="display:block;"><%= radio_button_tag 'type', type, 1==selected+=1 %> <%= name %></label>
10
  <% end %>
7
  <%= select_type_radio_buttons(params[:tab]) %>
11 8
  </p>
12 9
  </div>
13 10
  <p><%= submit_tag l(:label_next).html_safe + " &#187;".html_safe, :name => nil %></p>
test/helpers/custom_fields_helper_test.rb
95 95

  
96 96
    assert_select_in custom_field_tag('object', value), 'textarea[class=?]', 'text_cf wiki-edit'
97 97
  end
98

  
99
  def test_select_type_radio_buttons
100
    result = select_type_radio_buttons('UserCustomField')
101
    assert_select_in result, 'input[type="radio"]', :count => 10
102
    assert_select_in result, 'input#type_UserCustomField[checked=?]', 'checked'
103

  
104
    result = select_type_radio_buttons(nil)
105
    assert_select_in result, 'input[type="radio"]', :count => 10
106
    assert_select_in result, 'input#type_IssueCustomField[checked=?]', 'checked'
107
  end
98 108
end
(2-2/2)