Project

General

Profile

Patch #30994 » 0001-Move-custom-field-classes-to-a-method.patch

Marius BĂLTEANU, 2019-03-07 22:07

View differences:

app/helpers/issues_helper.rb
243 243
    half = (values.size / 2.0).ceil
244 244
    issue_fields_rows do |rows|
245 245
      values.each_with_index do |value, i|
246
        css = "cf_#{value.custom_field.id}"
247 246
        m = (i < half ? :left : :right)
248
        rows.send m, custom_field_name_tag(value.custom_field), custom_field_value_tag(value), :class => css
247
        rows.send m, custom_field_name_tag(value.custom_field), custom_field_value_tag(value), :class => value.custom_field.css_classes
249 248
      end
250 249
    end
251 250
  end
......
263 262
          content_tag('hr') +
264 263
          content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
265 264
          content_tag('div', attr_value_tag, class: 'value')
266
      s << content_tag('div', content, class: "cf_#{value.custom_field.id} attribute")
265
      s << content_tag('div', content, class: "#{value.custom_field.css_classes} attribute")
267 266
    end
268 267
    s
269 268
  end
app/models/custom_field.rb
301 301
    super(attr_name, *args)
302 302
  end
303 303

  
304
  def css_classes
305
    "cf_#{id}"
306
  end
307

  
304 308
  protected
305 309

  
306 310
  # Removes multiple values for the custom field after setting the multiple attribute to false
app/views/context_menus/issues.html.erb
104 104
  <% end %>
105 105

  
106 106
  <% @options_by_custom_field.each do |field, options| %>
107
    <li class="folder cf_<%= field.id %>">
107
    <li class="folder <%= field.css_classes %>">
108 108
      <a href="#" class="submenu"><%= field.name %></a>
109 109
      <ul>
110 110
      <% options.each do |text, value| %>
app/views/context_menus/time_entries.html.erb
22 22
  <% end %>
23 23

  
24 24
  <% @options_by_custom_field.each do |field, options| %>
25
    <li class="folder cf_<%= field.id %>">
25
    <li class="folder <%= field.css_classes %>">
26 26
      <a href="#" class="submenu"><%= field.name %></a>
27 27
      <ul>
28 28
      <% options.each do |text, value| %>
app/views/projects/show.html.erb
30 30
    <li><span class="label"><%=l(:field_homepage)%>:</span> <%= link_to_if uri_with_safe_scheme?(@project.homepage), @project.homepage, @project.homepage %></li>
31 31
  <% end %>
32 32
  <% render_custom_field_values(@project) do |custom_field, formatted| %>
33
    <li class="cf_<%= custom_field.id %>"><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li>
33
    <li class="<%= custom_field.css_classes %>"><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li>
34 34
  <% end %>
35 35
  </ul>
36 36
  <% end %>
app/views/users/show.html.erb
13 13
  <% end %>
14 14
  <% @user.visible_custom_field_values.each do |custom_value| %>
15 15
  <% if !custom_value.value.blank? %>
16
    <li class="cf_<%= custom_value.custom_field.id %>"><%= custom_value.custom_field.name %>: <%= show_value(custom_value) %></li>
16
    <li class="<%= custom_value.custom_field.css_classes %>"><%= custom_value.custom_field.name %>: <%= show_value(custom_value) %></li>
17 17
  <% end %>
18 18
  <% end %>
19 19
    <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
    (1-1/1)