Project

General

Profile

Feature #43959 ยป 0001-Show-wiki-toolbar-for-long-text-custom-fields-on-ver.patch

Patch by Brice Beaumesnil - Go MAEDA, 2026-04-16 11:54

View differences:

app/views/versions/_form.html.erb
16 16

  
17 17
<% @version.visible_custom_field_values.each do |value| %>
18 18
  <p><%= custom_field_tag_with_label :version, value %></p>
19
  <%= wikitoolbar_for("version_custom_field_values_#{value.custom_field_id}", preview_text_path) if value.custom_field.full_text_formatting? %>
19 20
<% end %>
20 21

  
21 22
</div>
test/functional/versions_custom_fields_visibility_test.rb
45 45
    cf1 = VersionCustomField.create!(:name => 'cf1', :field_format => 'string')
46 46
    cf2 = VersionCustomField.create!(:name => 'cf2', :field_format => 'string', :visible => false, :role_ids => [1])
47 47
    cf3 = VersionCustomField.create!(:name => 'cf3', :field_format => 'string', :visible => false, :role_ids => [3])
48
    cf4 = VersionCustomField.create!(:name => 'cf4', :field_format => 'text', :text_formatting => 'full')
48 49

  
49 50
    version = Version.find(2)
50
    version.custom_field_values = {cf1.id => 'Value1', cf2.id => 'Value2', cf3.id => 'Value3'}
51
    version.custom_field_values = {
52
      cf1.id => 'Value1',
53
      cf2.id => 'Value2',
54
      cf3.id => 'Value3',
55
      cf4.id => 'Formatted text'
56
    }
51 57
    version.save!
52 58

  
53 59
    @request.session[:user_id] = 2
......
58 64
      assert_select 'input[id=?]', "version_custom_field_values_#{cf1.id}"
59 65
      assert_select 'input[id=?]', "version_custom_field_values_#{cf2.id}"
60 66
      assert_select 'input[id=?]', "version_custom_field_values_#{cf3.id}", 0
67
      assert_select 'textarea[id=?].wiki-edit', "version_custom_field_values_#{cf4.id}"
61 68
    end
69
    # Wikitoolbar should be shown for cf4
70
    assert_select 'head script[src*=?]', 'jstoolbar'
62 71
  end
63 72
end
    (1-1/1)