Project

General

Profile

Patch #19122 » issue_layout_longtext_custom_fields.diff

updated version, from development - Rudy Herdier, 2015-02-17 19:06

View differences:

app/helpers/issues_helper.rb (copie de travail)
def render_custom_fields_rows(issue)
values = issue.visible_custom_field_values
return if values.empty?
#Don't take long text fields
non_longtext_values = []
values.compact.each do |value|
if !(value.custom_field.format.is_a?(Redmine::FieldFormat::TextFormat)) then
non_longtext_values << value
end
end
ordered_values = []
half = (values.size / 2.0).ceil
half = (non_longtext_values.size / 2.0).ceil
half.times do |i|
ordered_values << values[i]
ordered_values << values[i + half]
ordered_values << non_longtext_values[i]
ordered_values << non_longtext_values[i + half]
end
s = "<tr>\n"
n = 0
ordered_values.compact.each do |value|
css = "cf_#{value.custom_field.id}"
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
s << "\t<th class=\"#{css}\">#{ h(value.custom_field.name) }:</th><td class=\"#{css}\">#{ h(show_value(value)) }</td>\n"
s << "\t<th class=\"#{css}\">#{ h(value.custom_field.name) }:</th><td class=\"#{css}\">#{ h(show_value(value)) }</td>\n"
n += 1
end
s << "</tr>\n"
s.html_safe
end
def render_custom_fields_long_text_rows(issue)
values = issue.visible_custom_field_values
return if values.empty?
#Only take long text fields
longtext_values = []
values.compact.each do |value|
if value.custom_field.format.is_a?(Redmine::FieldFormat::TextFormat) then
longtext_values << value
end
end
s = "<tr>\n</tr>\n"
longtext_values.compact.each do |value|
css = "cf_#{value.custom_field.id}"
s << "<tr>\n<td class=\"#{css}\"></td>\n</tr>\n"
s << "<tr>\n\t<th class=\"#{css}\">#{ h(value.custom_field.name) }:</th>\n</tr>\n"
s << "<tr>\n\t<td class=\"#{css}\">#{ h(show_value(value)) }</td>\n</tr>\n"
s << "<tr>\n<td class=\"#{css}\"></td>\n</tr>\n"
end
s << "<tr>\n</tr>\n"
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)
app/views/issues/show.html.erb (copie de travail)
<%= textilizable @issue, :description, :attachments => @issue.attachments %>
</div>
</div>
<table class="attributes">
<%= render_custom_fields_long_text_rows(@issue) %>
</table>
<% end %>
<%= link_to_attachments @issue, :thumbnails => true %>
<% end -%>
(2-2/2)