Project

General

Profile

Feature #29712 » 0001-Show-Edit-Preview-tabs-for-full-width-layout-custom-.patch

Marius BĂLTEANU, 2019-02-03 21:37

View differences:

app/helpers/custom_fields_helper.rb
55 55
    items = []
56 56
    items << [l(:label_custom_field_plural), custom_fields_path]
57 57
    items << [l(custom_field.type_name), custom_fields_path(:tab => custom_field.class.name)] if custom_field
58
    items << (custom_field.nil? || custom_field.new_record? ? l(:label_custom_field_new) : custom_field.name) 
58
    items << (custom_field.nil? || custom_field.new_record? ? l(:label_custom_field_new) : custom_field.name)
59 59

  
60 60
    title(*items)
61 61
  end
......
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"
83
    css << ' wiki-edit' if custom_value.custom_field.full_text_formatting?
84

  
82 85
    custom_value.custom_field.format.edit_tag self,
83 86
      custom_field_tag_id(prefix, custom_value.custom_field),
84 87
      custom_field_tag_name(prefix, custom_value.custom_field),
85 88
      custom_value,
86
      :class => "#{custom_value.custom_field.field_format}_cf"
89
      :class => css
87 90
  end
88 91

  
89 92
  # Return custom field name tag
......
92 95
    css = title ? "field-description" : nil
93 96
    content_tag 'span', custom_field.name, :title => title, :class => css
94 97
  end
95
  
98

  
96 99
  # Return custom field label tag
97 100
  def custom_field_label_tag(name, custom_value, options={})
98 101
    required = options[:required] || custom_value.custom_field.is_required?
app/models/custom_field.rb
190 190
    full_width_layout == '1'
191 191
  end
192 192

  
193
  def full_text_formatting?
194
    text_formatting == 'full'
195
  end
196

  
193 197
  # Returns a ORDER BY clause that can used to sort customized
194 198
  # objects by their value of the custom field.
195 199
  # Returns nil if the custom field can not be used for sorting.
app/views/issues/_form_custom_fields.html.erb
20 20

  
21 21
<% custom_field_values_full_width.each do |value| %>
22 22
  <p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p>
23
  <%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) if value.custom_field.full_text_formatting? %>
23 24
<% end %>
test/helpers/custom_fields_helper_test.rb
86 86
    assert_select_in custom_field_tag_for_bulk_edit('object', field),
87 87
      'input[type=text][value=""][name=?]', 'object[custom_field_values][52]'
88 88
  end
89

  
90
  def test_custom_field_tag_class_should_contain_wiki_edit_for_custom_fields_with_full_text_formatting
91
    field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :text_formatting => 'full')
92
    value = CustomValue.new(:value => 'bar', :custom_field => field)
93

  
94
    assert_select_in custom_field_tag('object', value), 'textarea[class=?]', 'text_cf wiki-edit'
95
  end
89 96
end
test/unit/custom_field_test.rb
362 362
      refute_includes Project.where(project_field.visibility_by_project_condition), project
363 363
    end
364 364
  end
365

  
366
  def test_full_text_formatting?
367
    field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :text_formatting => 'full')
368
    assert field.full_text_formatting?
369

  
370
    field2 = IssueCustomField.create!(:name => 'Another long text', :field_format => 'text')
371
    assert !field2.full_text_formatting?
372
  end
365 373
end
(4-4/5)