Project

General

Profile

Patch #21705 » option_to_show_fields_under_description.patch

Marius BĂLTEANU, 2016-01-12 22:39

View differences:

app/helpers/issues_helper.rb
end
end
def render_custom_fields_rows_above_desc(issue)
values = issue.visible_custom_field_values_by_position
return if values.empty?
half = (values.size / 2.0).ceil
issue_fields_rows do |rows|
values.each_with_index do |value, i|
css = "cf_#{value.custom_field.id}"
m = (i < half ? :left : :right)
rows.send m, custom_field_name_tag(value.custom_field), show_value(value), :class => css
end
end
end
def render_custom_fields_rows_under_desc(issue)
values = issue.visible_custom_field_values_by_position(nil, true)
return if values.empty?
s = ''
values.each_with_index do |value, i|
content =
content_tag('hr') +
content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
content_tag('div', show_value(value), class: 'value')
s << content_tag('div', content, class: "cf_#{value.custom_field.id}")
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)
app/models/issue.rb
end
end
# Returns the custom fields depending on the attribute
# show_under_description
def visible_custom_field_values_by_position(user=nil, under_description=false)
user_real = user || User.current
custom_field_values.select do |value|
if under_description == false
value.custom_field.visible_by?(project, user_real) unless value.custom_field.show_under_description?
else
value.custom_field.visible_by?(project, user_real) && value.custom_field.show_under_description?
end
end
end
# Copies attributes from another issue, arg can be an id or an Issue
def copy_from(arg, options={})
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
app/views/custom_fields/formats/_text.html.erb
<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
<p><%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %></p>
<p><%= f.check_box :show_under_description, {:label => :setting_show_under_description} %></p>
<p><%= f.text_area(:default_value, :rows => 5) %></p>
app/views/issues/show.html.erb
end
end
end %>
<%= render_custom_fields_rows(@issue) %>
<%= render_custom_fields_rows_above_desc(@issue) %>
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
</div>
......
<%= link_to_attachments @issue, :thumbnails => true %>
<% end -%>
<%= render_custom_fields_rows_under_desc(@issue) %>
<%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
<% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
config/locales/en.yml
setting_search_results_per_page: Search results per page
setting_attachment_extensions_allowed: Allowed extensions
setting_attachment_extensions_denied: Disallowed extensions
setting_show_under_description: Show under description
permission_add_project: Create project
permission_add_subprojects: Create subprojects
-
db/migrate/20160107180443_add_custom_fields_show_under_description.rb
class AddCustomFieldsShowUnderDescription < ActiveRecord::Migration
def self.up
add_column :custom_fields, :show_under_description, :boolean, :default => false
end
def self.down
remove_column :custom_fields, :show_under_description
end
end
(3-3/8)