Commit 69831302 authored by maeda's avatar maeda

Show Edit/Preview tabs for full width layout custom fields with text formatting enabled (#29712).

Patch by Marius BALTEANU.


git-svn-id: https://svn.redmine.org/redmine/trunk@17858 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent b6febc9a
...@@ -55,7 +55,7 @@ module CustomFieldsHelper ...@@ -55,7 +55,7 @@ module CustomFieldsHelper
items = [] items = []
items << [l(:label_custom_field_plural), custom_fields_path] items << [l(:label_custom_field_plural), custom_fields_path]
items << [l(custom_field.type_name), custom_fields_path(:tab => custom_field.class.name)] if custom_field items << [l(custom_field.type_name), custom_fields_path(:tab => custom_field.class.name)] if custom_field
items << (custom_field.nil? || custom_field.new_record? ? l(:label_custom_field_new) : custom_field.name) items << (custom_field.nil? || custom_field.new_record? ? l(:label_custom_field_new) : custom_field.name)
title(*items) title(*items)
end end
...@@ -79,11 +79,14 @@ module CustomFieldsHelper ...@@ -79,11 +79,14 @@ module CustomFieldsHelper
# Return custom field html tag corresponding to its format # Return custom field html tag corresponding to its format
def custom_field_tag(prefix, custom_value) def custom_field_tag(prefix, custom_value)
css = "#{custom_value.custom_field.field_format}_cf"
css << ' wiki-edit' if custom_value.custom_field.full_text_formatting?
custom_value.custom_field.format.edit_tag self, custom_value.custom_field.format.edit_tag self,
custom_field_tag_id(prefix, custom_value.custom_field), custom_field_tag_id(prefix, custom_value.custom_field),
custom_field_tag_name(prefix, custom_value.custom_field), custom_field_tag_name(prefix, custom_value.custom_field),
custom_value, custom_value,
:class => "#{custom_value.custom_field.field_format}_cf" :class => css
end end
# Return custom field name tag # Return custom field name tag
...@@ -92,7 +95,7 @@ module CustomFieldsHelper ...@@ -92,7 +95,7 @@ module CustomFieldsHelper
css = title ? "field-description" : nil css = title ? "field-description" : nil
content_tag 'span', custom_field.name, :title => title, :class => css content_tag 'span', custom_field.name, :title => title, :class => css
end end
# Return custom field label tag # Return custom field label tag
def custom_field_label_tag(name, custom_value, options={}) def custom_field_label_tag(name, custom_value, options={})
required = options[:required] || custom_value.custom_field.is_required? required = options[:required] || custom_value.custom_field.is_required?
......
...@@ -190,6 +190,10 @@ class CustomField < ActiveRecord::Base ...@@ -190,6 +190,10 @@ class CustomField < ActiveRecord::Base
full_width_layout == '1' full_width_layout == '1'
end end
def full_text_formatting?
text_formatting == 'full'
end
# Returns a ORDER BY clause that can used to sort customized # Returns a ORDER BY clause that can used to sort customized
# objects by their value of the custom field. # objects by their value of the custom field.
# Returns nil if the custom field can not be used for sorting. # Returns nil if the custom field can not be used for sorting.
......
...@@ -20,4 +20,5 @@ ...@@ -20,4 +20,5 @@
<% custom_field_values_full_width.each do |value| %> <% custom_field_values_full_width.each do |value| %>
<p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p> <p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p>
<%= 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? %>
<% end %> <% end %>
...@@ -86,4 +86,11 @@ class CustomFieldsHelperTest < Redmine::HelperTest ...@@ -86,4 +86,11 @@ class CustomFieldsHelperTest < Redmine::HelperTest
assert_select_in custom_field_tag_for_bulk_edit('object', field), assert_select_in custom_field_tag_for_bulk_edit('object', field),
'input[type=text][value=""][name=?]', 'object[custom_field_values][52]' 'input[type=text][value=""][name=?]', 'object[custom_field_values][52]'
end end
def test_custom_field_tag_class_should_contain_wiki_edit_for_custom_fields_with_full_text_formatting
field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :text_formatting => 'full')
value = CustomValue.new(:value => 'bar', :custom_field => field)
assert_select_in custom_field_tag('object', value), 'textarea[class=?]', 'text_cf wiki-edit'
end
end end
...@@ -362,4 +362,12 @@ class CustomFieldTest < ActiveSupport::TestCase ...@@ -362,4 +362,12 @@ class CustomFieldTest < ActiveSupport::TestCase
refute_includes Project.where(project_field.visibility_by_project_condition), project refute_includes Project.where(project_field.visibility_by_project_condition), project
end end
end end
def test_full_text_formatting?
field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :text_formatting => 'full')
assert field.full_text_formatting?
field2 = IssueCustomField.create!(:name => 'Another long text', :field_format => 'text')
assert !field2.full_text_formatting?
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment