From 180f131b377dee07a4478a9d10851e0114e89b61 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 29 Sep 2026 16:56:39 +0900 Subject: [PATCH] Show wiki toolbar for long text custom fields on objects other than issues --- app/views/documents/_form.html.erb | 1 + app/views/enumerations/_form.html.erb | 1 + app/views/groups/_form.html.erb | 1 + app/views/issues/_edit.html.erb | 3 ++ app/views/projects/_form.html.erb | 1 + app/views/versions/_form.html.erb | 2 ++ test/functional/versions_controller_test.rb | 4 +++ test/integration/custom_fields_test.rb | 39 +++++++++++++++++++++ 8 files changed, 52 insertions(+) create mode 100644 test/integration/custom_fields_test.rb diff --git a/app/views/documents/_form.html.erb b/app/views/documents/_form.html.erb index 7b73673cd..3796cf39f 100644 --- a/app/views/documents/_form.html.erb +++ b/app/views/documents/_form.html.erb @@ -11,6 +11,7 @@ <% @document.custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :document, value %>

+ <%= wikitoolbar_for "document_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %> <% end %> <% if @document.new_record? %> diff --git a/app/views/enumerations/_form.html.erb b/app/views/enumerations/_form.html.erb index 8ff774d9d..c3cd54b6f 100644 --- a/app/views/enumerations/_form.html.erb +++ b/app/views/enumerations/_form.html.erb @@ -7,5 +7,6 @@ <% @enumeration.custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :enumeration, value %>

+ <%= wikitoolbar_for "enumeration_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %> <% end %> diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb index 723b9f203..236eed167 100644 --- a/app/views/groups/_form.html.erb +++ b/app/views/groups/_form.html.erb @@ -15,5 +15,6 @@ <% @group.custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :group, value %>

+ <%= wikitoolbar_for "group_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %> <% end %> diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index f86fb07eb..3aa28b74c 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -24,6 +24,9 @@

<%= time_entry.text_field :comments, :size => 60 %>

<% @time_entry.editable_custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :time_entry, value %>

+ <% if value.custom_field.full_text_formatting? %> + <%= wikitoolbar_for "time_entry_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @project, :issue_id => @issue) %> + <% end %> <% end %> <% end %> diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index 33c801032..7b47584c8 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -27,6 +27,7 @@ <% @project.visible_custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :project, value %>

+ <%= wikitoolbar_for "project_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? %> <% end %> <%= call_hook(:view_projects_form, :project => @project, :form => f) %> diff --git a/app/views/versions/_form.html.erb b/app/views/versions/_form.html.erb index 62119769b..a6f2bd0de 100644 --- a/app/views/versions/_form.html.erb +++ b/app/views/versions/_form.html.erb @@ -16,6 +16,8 @@ <% @version.visible_custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :version, value %>

+ <%# The wiki toolbar is not styled in the modal opened from the issue form %> + <%= wikitoolbar_for "version_custom_field_values_#{value.custom_field_id}" if value.custom_field.full_text_formatting? && !request.xhr? %> <% end %> diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb index 382b555f9..dfec8da7d 100644 --- a/test/functional/versions_controller_test.rb +++ b/test/functional/versions_controller_test.rb @@ -251,10 +251,14 @@ class VersionsControllerTest < Redmine::ControllerTest end def test_new_from_issue_form + cf = VersionCustomField.generate!(:field_format => 'text', :text_formatting => 'full') @request.session[:user_id] = 2 get :new, :params => {:project_id => '1'}, :xhr => true assert_response :success assert_equal 'text/javascript', response.media_type + # The wiki toolbar is not displayed in the modal + assert_include "version_custom_field_values_#{cf.id}", response.body + assert_not_include 'jsToolBar', response.body end def test_create diff --git a/test/integration/custom_fields_test.rb b/test/integration/custom_fields_test.rb new file mode 100644 index 000000000..ffa46d52d --- /dev/null +++ b/test/integration/custom_fields_test.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +# Redmine - project management software +# Copyright (C) 2006- Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require_relative '../test_helper' + +class CustomFieldsTest < Redmine::IntegrationTest + def test_wiki_toolbar_should_be_displayed_for_full_text_formatting_custom_fields + log_user('admin', 'admin') + { + VersionCustomField => ['/projects/ecookbook/versions/new', 'version'], + ProjectCustomField => ['/projects/ecookbook/settings', 'project'], + TimeEntryActivityCustomField => ['/enumerations/new?type=TimeEntryActivity', 'enumeration'], + DocumentCustomField => ['/projects/ecookbook/documents/new', 'document'], + GroupCustomField => ['/groups/new', 'group'], + TimeEntryCustomField => ['/issues/1/edit', 'time_entry'] + }.each do |klass, (path, prefix)| + cf = klass.generate!(:field_format => 'text', :text_formatting => 'full') + get path + assert_response :success + assert_select 'script', :text => /getElementById\('#{prefix}_custom_field_values_#{cf.id}'\)/ + end + end +end -- 2.55.0