From b40d66f39fa8a0425ce2a08d4cf4007d814b97fb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 25 Jan 2017 14:55:36 +0000 Subject: Option for long text custom fields to be displayed under the description field (#21705). Based on patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@16251 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/issues_helper.rb | 24 ++++++++++++++++++++++-- app/models/custom_field.rb | 7 ++++++- app/views/custom_fields/formats/_text.html.erb | 3 +++ app/views/issues/_form_custom_fields.html.erb | 7 +++++++ app/views/issues/show.html.erb | 4 +++- 5 files changed, 41 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 122c2ffca..29f469121 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -239,8 +239,8 @@ module IssuesHelper r.to_html end - def render_custom_fields_rows(issue) - values = issue.visible_custom_field_values + def render_half_width_custom_fields_rows(issue) + values = issue.visible_custom_field_values.reject {|value| value.custom_field.full_width_layout?} return if values.empty? half = (values.size / 2.0).ceil issue_fields_rows do |rows| @@ -252,6 +252,26 @@ module IssuesHelper end end + def render_full_width_custom_fields_rows(issue) + values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?} + return if values.empty? + + s = '' + values.each_with_index do |value, i| + if value.custom_field.text_formatting == 'full' + attr_value = content_tag('div', show_value(value), class: 'wiki') + else + attr_value = show_value(value) + end + content = + content_tag('hr') + + content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) + + content_tag('div', attr_value, class: 'value') + s << content_tag('div', content, class: "cf_#{value.custom_field.id} attribute") + end + s.html_safe + end + # Returns the path for updating the issue form # with project as the current project def update_issue_form_path(project, issue) diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 717df95e8..72cf0ea7c 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -89,7 +89,8 @@ class CustomField < ActiveRecord::Base 'edit_tag_style', 'user_role', 'version_status', - 'extensions_allowed' + 'extensions_allowed', + 'full_width_layout' def format @format ||= Redmine::FieldFormat.find(field_format) @@ -186,6 +187,10 @@ class CustomField < ActiveRecord::Base format.totalable_supported end + def full_width_layout? + full_width_layout == '1' + end + # Returns a ORDER BY clause that can used to sort customized # objects by their value of the custom field. # Returns nil if the custom field can not be used for sorting. diff --git a/app/views/custom_fields/formats/_text.html.erb b/app/views/custom_fields/formats/_text.html.erb index e72dcab42..79ea7c5e6 100644 --- a/app/views/custom_fields/formats/_text.html.erb +++ b/app/views/custom_fields/formats/_text.html.erb @@ -1,3 +1,6 @@ <%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>

<%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %>

+<% if @custom_field.class.name == "IssueCustomField" %> +

<%= f.check_box :full_width_layout %>

+<% end %>

<%= f.text_area(:default_value, :rows => 5) %>

diff --git a/app/views/issues/_form_custom_fields.html.erb b/app/views/issues/_form_custom_fields.html.erb index 2e12c00e8..13bedd546 100644 --- a/app/views/issues/_form_custom_fields.html.erb +++ b/app/views/issues/_form_custom_fields.html.erb @@ -1,4 +1,7 @@ <% custom_field_values = @issue.editable_custom_field_values %> +<% custom_field_values_full_width = custom_field_values.select { |value| value.custom_field.full_width_layout? } %> +<% custom_field_values -= custom_field_values_full_width %> + <% if custom_field_values.present? %>
@@ -14,3 +17,7 @@
<% end %> + +<% custom_field_values_full_width.each do |value| %> +

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

+<% end %> diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index b9e5111fa..9d767f0b1 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -66,7 +66,7 @@ end end end %> -<%= render_custom_fields_rows(@issue) %> +<%= render_half_width_custom_fields_rows(@issue) %> <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %> @@ -87,6 +87,8 @@ end %> <%= link_to_attachments @issue, :thumbnails => true %> <% end -%> +<%= render_full_width_custom_fields_rows(@issue) %> + <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %> <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %> -- cgit v1.2.3