0002-Unify-css-classes-for-custom-fields-in-issue-show-is.patch

Marius BALTEANU, 2020-04-05 10:45

Download (3.62 KB)

View differences:

app/helpers/custom_fields_helper.rb
79 79

  
80 80
  # Return custom field html tag corresponding to its format
81 81
  def custom_field_tag(prefix, custom_value)
82
    css = "#{custom_value.custom_field.field_format}_cf"
82
    css = custom_value.custom_field.css_classes
83 83
    data = nil
84 84
    if custom_value.custom_field.full_text_formatting?
85 85
      css += ' wiki-edit'
......
135 135
      custom_field,
136 136
      objects,
137 137
      value,
138
      :class => "#{custom_field.field_format}_cf")
138
      :class => custom_field.css_classes)
139 139
  end
140 140

  
141 141
  # Returns custom field value tag
app/models/custom_field.rb
306 306
  end
307 307

  
308 308
  def css_classes
309
    "cf_#{id}"
309
    "#{field_format}_cf cf_#{id}"
310 310
  end
311 311

  
312 312
  protected
test/functional/projects_controller_test.rb
677 677
    ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
678 678
    get(:show, :params => {:id => 'ecookbook'})
679 679
    assert_response :success
680
    assert_select 'li[class=?]', 'cf_3', :text => /Development status/
680
    assert_select 'li.list_cf.cf_3', :text => /Development status/
681 681
  end
682 682

  
683 683
  def test_show_should_not_display_hidden_custom_fields
test/functional/users_controller_test.rb
141 141
    get :show, :params => {:id => 2}
142 142
    assert_response :success
143 143

  
144
    assert_select 'li[class=?]', 'cf_4', :text => /Phone number/
144
    assert_select 'li.cf_4.string_cf', :text => /Phone number/
145 145
  end
146 146

  
147 147
  def test_show_should_not_display_hidden_custom_fields
test/helpers/custom_fields_helper_test.rb
93 93
    field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :text_formatting => 'full')
94 94
    value = CustomValue.new(:value => 'bar', :custom_field => field)
95 95

  
96
    assert_select_in custom_field_tag('object', value), 'textarea[class=?]', 'text_cf wiki-edit'
96
    assert_select_in custom_field_tag('object', value), "textarea.text_cf.wiki-edit.cf_#{field.id}"
97 97
  end
98 98

  
99 99
  def test_select_type_radio_buttons
100
-