##// END OF EJS Templates
Option for long text custom fields to be displayed under the description field (#21705)....
Jean-Philippe Lang -
r15869:b40d66f39fa8
parent child
Show More
@@ -239,8 +239,8 module IssuesHelper
239 r.to_html
239 r.to_html
240 end
240 end
241
241
242 def render_custom_fields_rows(issue)
242 def render_half_width_custom_fields_rows(issue)
243 values = issue.visible_custom_field_values
243 values = issue.visible_custom_field_values.reject {|value| value.custom_field.full_width_layout?}
244 return if values.empty?
244 return if values.empty?
245 half = (values.size / 2.0).ceil
245 half = (values.size / 2.0).ceil
246 issue_fields_rows do |rows|
246 issue_fields_rows do |rows|
@@ -252,6 +252,26 module IssuesHelper
252 end
252 end
253 end
253 end
254
254
255 def render_full_width_custom_fields_rows(issue)
256 values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?}
257 return if values.empty?
258
259 s = ''
260 values.each_with_index do |value, i|
261 if value.custom_field.text_formatting == 'full'
262 attr_value = content_tag('div', show_value(value), class: 'wiki')
263 else
264 attr_value = show_value(value)
265 end
266 content =
267 content_tag('hr') +
268 content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
269 content_tag('div', attr_value, class: 'value')
270 s << content_tag('div', content, class: "cf_#{value.custom_field.id} attribute")
271 end
272 s.html_safe
273 end
274
255 # Returns the path for updating the issue form
275 # Returns the path for updating the issue form
256 # with project as the current project
276 # with project as the current project
257 def update_issue_form_path(project, issue)
277 def update_issue_form_path(project, issue)
@@ -89,7 +89,8 class CustomField < ActiveRecord::Base
89 'edit_tag_style',
89 'edit_tag_style',
90 'user_role',
90 'user_role',
91 'version_status',
91 'version_status',
92 'extensions_allowed'
92 'extensions_allowed',
93 'full_width_layout'
93
94
94 def format
95 def format
95 @format ||= Redmine::FieldFormat.find(field_format)
96 @format ||= Redmine::FieldFormat.find(field_format)
@@ -186,6 +187,10 class CustomField < ActiveRecord::Base
186 format.totalable_supported
187 format.totalable_supported
187 end
188 end
188
189
190 def full_width_layout?
191 full_width_layout == '1'
192 end
193
189 # Returns a ORDER BY clause that can used to sort customized
194 # Returns a ORDER BY clause that can used to sort customized
190 # objects by their value of the custom field.
195 # objects by their value of the custom field.
191 # Returns nil if the custom field can not be used for sorting.
196 # Returns nil if the custom field can not be used for sorting.
@@ -1,3 +1,6
1 <%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
1 <%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
2 <p><%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %></p>
2 <p><%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %></p>
3 <% if @custom_field.class.name == "IssueCustomField" %>
4 <p><%= f.check_box :full_width_layout %></p>
5 <% end %>
3 <p><%= f.text_area(:default_value, :rows => 5) %></p>
6 <p><%= f.text_area(:default_value, :rows => 5) %></p>
@@ -1,4 +1,7
1 <% custom_field_values = @issue.editable_custom_field_values %>
1 <% custom_field_values = @issue.editable_custom_field_values %>
2 <% custom_field_values_full_width = custom_field_values.select { |value| value.custom_field.full_width_layout? } %>
3 <% custom_field_values -= custom_field_values_full_width %>
4
2 <% if custom_field_values.present? %>
5 <% if custom_field_values.present? %>
3 <div class="splitcontent">
6 <div class="splitcontent">
4 <div class="splitcontentleft">
7 <div class="splitcontentleft">
@@ -14,3 +17,7
14 </div>
17 </div>
15 </div>
18 </div>
16 <% end %>
19 <% end %>
20
21 <% custom_field_values_full_width.each do |value| %>
22 <p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p>
23 <% end %>
@@ -66,7 +66,7
66 end
66 end
67 end
67 end
68 end %>
68 end %>
69 <%= render_custom_fields_rows(@issue) %>
69 <%= render_half_width_custom_fields_rows(@issue) %>
70 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
70 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
71 </div>
71 </div>
72
72
@@ -87,6 +87,8 end %>
87 <%= link_to_attachments @issue, :thumbnails => true %>
87 <%= link_to_attachments @issue, :thumbnails => true %>
88 <% end -%>
88 <% end -%>
89
89
90 <%= render_full_width_custom_fields_rows(@issue) %>
91
90 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
92 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
91
93
92 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
94 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
@@ -372,6 +372,7 en:
372 field_textarea_font: Font used for text areas
372 field_textarea_font: Font used for text areas
373 field_updated_by: Updated by
373 field_updated_by: Updated by
374 field_last_updated_by: Last updated by
374 field_last_updated_by: Last updated by
375 field_full_width_layout: Full width layout
375
376
376 setting_app_title: Application title
377 setting_app_title: Application title
377 setting_app_subtitle: Application subtitle
378 setting_app_subtitle: Application subtitle
@@ -384,6 +384,7 fr:
384 field_textarea_font: Police utilisée pour les champs texte
384 field_textarea_font: Police utilisée pour les champs texte
385 field_updated_by: Mise à jour par
385 field_updated_by: Mise à jour par
386 field_last_updated_by: Dernière mise à jour par
386 field_last_updated_by: Dernière mise à jour par
387 field_full_width_layout: Afficher sur toute la largeur
387
388
388 setting_app_title: Titre de l'application
389 setting_app_title: Titre de l'application
389 setting_app_subtitle: Sous-titre de l'application
390 setting_app_subtitle: Sous-titre de l'application
@@ -108,7 +108,7 module Redmine
108 CustomField.store_accessor :format_store, *args
108 CustomField.store_accessor :format_store, *args
109 end
109 end
110
110
111 field_attributes :url_pattern
111 field_attributes :url_pattern, :full_width_layout
112
112
113 def name
113 def name
114 self.class.format_name
114 self.class.format_name
@@ -463,8 +463,8 div.issue div.subject h3 {margin: 0; margin-bottom: 0.1em;}
463 div.issue span.private, div.journal span.private { position:relative; bottom: 2px; text-transform: uppercase; background: #d22; color: #fff; font-weight:bold; padding: 0px 2px 0px 2px; font-size: 60%; margin-right: 2px; border-radius: 2px;}
463 div.issue span.private, div.journal span.private { position:relative; bottom: 2px; text-transform: uppercase; background: #d22; color: #fff; font-weight:bold; padding: 0px 2px 0px 2px; font-size: 60%; margin-right: 2px; border-radius: 2px;}
464 div.issue .next-prev-links {color:#999;}
464 div.issue .next-prev-links {color:#999;}
465 div.issue .attributes {margin-top: 2em;}
465 div.issue .attributes {margin-top: 2em;}
466 div.issue .attribute {padding-left:180px; clear:left; min-height: 1.8em;}
466 div.issue .attributes .attribute {padding-left:180px; clear:left; min-height: 1.8em;}
467 div.issue .attribute .label {width: 170px; margin-left:-180px; font-weight:bold; float:left; overflow:hidden; text-overflow: ellipsis;}
467 div.issue .attributes .attribute .label {width: 170px; margin-left:-180px; font-weight:bold; float:left; overflow:hidden; text-overflow: ellipsis;}
468 div.issue .attribute .value {overflow:hidden; text-overflow: ellipsis;}
468 div.issue .attribute .value {overflow:hidden; text-overflow: ellipsis;}
469 div.issue.overdue .due-date .value { color: #c22; }
469 div.issue.overdue .due-date .value { color: #c22; }
470
470
@@ -126,6 +126,20 class CustomFieldsControllerTest < Redmine::ControllerTest
126 assert_select '[name=?]', 'custom_field[default_value]', 0
126 assert_select '[name=?]', 'custom_field[default_value]', 0
127 end
127 end
128
128
129 def test_setting_full_width_layout_shoul_be_present_only_for_long_text_issue_custom_field
130 get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'text'}
131 assert_response :success
132 assert_select '[name=?]', 'custom_field[full_width_layout]'
133
134 get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}
135 assert_response :success
136 assert_select '[name=?]', 'custom_field[full_width_layout]', 0
137
138 get :new, :type => 'TimeEntryCustomField', :custom_field => {:field_format => 'text'}
139 assert_response :success
140 assert_select '[name=?]', 'custom_field[full_width_layout]', 0
141 end
142
129 def test_new_js
143 def test_new_js
130 xhr :get, :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js'
144 xhr :get, :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js'
131 assert_response :success
145 assert_response :success
@@ -1575,6 +1575,25 class IssuesControllerTest < Redmine::ControllerTest
1575 assert_select ".cf_1 .value", :text => 'MySQL, Oracle'
1575 assert_select ".cf_1 .value", :text => 'MySQL, Oracle'
1576 end
1576 end
1577
1577
1578 def test_show_with_full_width_layout_custom_field_should_show_field_under_description
1579 field = IssueCustomField.create!(:name => 'Long text', :field_format => 'text', :full_width_layout => '1',
1580 :tracker_ids => [1], :is_for_all => true)
1581 issue = Issue.find(1)
1582 issue.custom_field_values = {field.id => 'This is a long text'}
1583 issue.save!
1584
1585 get :show, :id => 1
1586 assert_response :success
1587
1588 # long text custom field should not be render in the attributes div
1589 assert_select "div.attributes div.attribute.cf_#{field.id} p strong", 0, :text => 'Long text'
1590 assert_select "div.attributes div.attribute.cf_#{field.id} div.value", 0, :text => 'This is a long text'
1591
1592 # long text custom field should be render under description field
1593 assert_select "div.description ~ div.attribute.cf_#{field.id} p strong", :text => 'Long text'
1594 assert_select "div.description ~ div.attribute.cf_#{field.id} div.value", :text => 'This is a long text'
1595 end
1596
1578 def test_show_with_multi_user_custom_field
1597 def test_show_with_multi_user_custom_field
1579 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1598 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1580 :tracker_ids => [1], :is_for_all => true)
1599 :tracker_ids => [1], :is_for_all => true)
General Comments 0
You need to be logged in to leave comments. Login now