Project

General

Profile

Feature #43959 » 0001-Show-wiki-toolbar-for-long-text-custom-fields-on-obj.patch

Go MAEDA, 2026-09-29 10:50

View differences:

app/views/documents/_form.html.erb
11 11
  <% @document.custom_field_values.each do |value| %>
12 12
    <p><%= custom_field_tag_with_label :document, value %></p>
13
    <%= wikitoolbar_for "document_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %>
13 14
  <% end %>
14 15
  <% if @document.new_record? %>
app/views/enumerations/_form.html.erb
7 7
  <% @enumeration.custom_field_values.each do |value| %>
8 8
    <p><%= custom_field_tag_with_label :enumeration, value %></p>
9
    <%= wikitoolbar_for "enumeration_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %>
9 10
  <% end %>
10 11
</div>
app/views/groups/_form.html.erb
15 15
  <% @group.custom_field_values.each do |value| %>
16 16
    <p><%= custom_field_tag_with_label :group, value %></p>
17
    <%= wikitoolbar_for "group_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %>
17 18
  <% end %>
18 19
</div>
app/views/issues/_edit.html.erb
24 24
        <p><%= time_entry.text_field :comments, :size => 60 %></p>
25 25
        <% @time_entry.editable_custom_field_values.each do |value| %>
26 26
          <p><%= custom_field_tag_with_label :time_entry, value %></p>
27
          <% if value.custom_field.full_text_formatting? %>
28
            <%= wikitoolbar_for "time_entry_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @project, :issue_id => @issue) %>
29
          <% end %>
27 30
        <% end %>
28 31
        <% end %>
29 32
    </fieldset>
app/views/projects/_form.html.erb
27 27
<% @project.visible_custom_field_values.each do |value| %>
28 28
  <p><%= custom_field_tag_with_label :project, value %></p>
29
  <%= wikitoolbar_for "project_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %>
29 30
<% end %>
30 31
<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
31 32
</div>
app/views/versions/_form.html.erb
16 16
<% @version.visible_custom_field_values.each do |value| %>
17 17
  <p><%= custom_field_tag_with_label :version, value %></p>
18
  <%# The wiki toolbar is not styled in the modal opened from the issue form %>
19
  <%= wikitoolbar_for "version_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? && !request.xhr? %>
18 20
<% end %>
19 21
</div>
test/functional/versions_controller_test.rb
251 251
  end
252 252
  def test_new_from_issue_form
253
    cf = VersionCustomField.generate!(:field_format => 'text', :text_formatting => 'full')
253 254
    @request.session[:user_id] = 2
254 255
    get :new, :params => {:project_id => '1'}, :xhr => true
255 256
    assert_response :success
256 257
    assert_equal 'text/javascript', response.media_type
258
    # The wiki toolbar is not displayed in the modal
259
    assert_include "version_custom_field_values_#{cf.id}", response.body
260
    assert_not_include 'jsToolBar', response.body
257 261
  end
258 262
  def test_create
test/integration/custom_fields_test.rb
1
# frozen_string_literal: true
2

  
3
# Redmine - project management software
4
# Copyright (C) 2006-  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
require_relative '../test_helper'
21

  
22
class CustomFieldsTest < Redmine::IntegrationTest
23
  def test_wiki_toolbar_should_be_displayed_for_full_text_formatting_custom_fields
24
    log_user('admin', 'admin')
25
    {
26
      VersionCustomField => ['/projects/ecookbook/versions/new', 'version'],
27
      ProjectCustomField => ['/projects/ecookbook/settings', 'project'],
28
      TimeEntryActivityCustomField => ['/enumerations/new?type=TimeEntryActivity', 'enumeration'],
29
      DocumentCustomField => ['/projects/ecookbook/documents/new', 'document'],
30
      GroupCustomField => ['/groups/new', 'group'],
31
      TimeEntryCustomField => ['/issues/1/edit', 'time_entry']
32
    }.each do |klass, (path, prefix)|
33
      cf = klass.generate!(:field_format => 'text', :text_formatting => 'full')
34
      get path
35
      assert_response :success
36
      assert_select 'script', :text => /getElementById\('#{prefix}_custom_field_values_#{cf.id}'\)/
37
    end
38
  end
39
end
(2-2/2)