1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-31 11:37:14 +00:00

Hooks for queries helper (#34743).

Patch by Alexander Meindl.


git-svn-id: http://svn.redmine.org/redmine/trunk@21068 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2021-07-14 14:02:02 +00:00
parent d496d8c4ed
commit 9fcf5af844

View File

@ -231,44 +231,56 @@ module QueriesHelper
def column_content(column, item)
value = column.value_object(item)
if value.is_a?(Array)
values = value.collect {|v| column_value(column, item, v)}.compact
safe_join(values, ', ')
else
column_value(column, item, value)
end
content =
if value.is_a?(Array)
values = value.collect {|v| column_value(column, item, v)}.compact
safe_join(values, ', ')
else
column_value(column, item, value)
end
call_hook(:helper_queries_column_content,
{:content => content, :column => column, :item => item})
content
end
def column_value(column, item, value)
case column.name
when :id
link_to value, issue_path(item)
when :subject
link_to value, issue_path(item)
when :parent
value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : ''
when :description
item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : ''
when :last_notes
item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : ''
when :done_ratio
progress_bar(value)
when :relations
content_tag(
'span',
value.to_s(item) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
:class => value.css_classes_for(item))
when :hours, :estimated_hours, :total_estimated_hours
format_hours(value)
when :spent_hours
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "#{item.id}"))
when :total_spent_hours
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}"))
when :attachments
value.to_a.map {|a| format_object(a)}.join(" ").html_safe
else
format_object(value)
end
content =
case column.name
when :id
link_to value, issue_path(item)
when :subject
link_to value, issue_path(item)
when :parent
value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : ''
when :description
item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : ''
when :last_notes
item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : ''
when :done_ratio
progress_bar(value)
when :relations
content_tag(
'span',
value.to_s(item) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
:class => value.css_classes_for(item))
when :hours, :estimated_hours, :total_estimated_hours
format_hours(value)
when :spent_hours
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "#{item.id}"))
when :total_spent_hours
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}"))
when :attachments
value.to_a.map {|a| format_object(a)}.join(" ").html_safe
else
format_object(value)
end
call_hook(:helper_queries_column_value,
{:content => content, :column => column, :item => item, :value => value})
content
end
def csv_content(column, item)