From: Go MAEDA Date: Wed, 14 Jul 2021 14:02:02 +0000 (+0000) Subject: Hooks for queries helper (#34743). X-Git-Tag: 5.0.0~343 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9fcf5af844ec223675cee32c2c52947be2f0669f;p=redmine.git Hooks for queries helper (#34743). Patch by Alexander Meindl. git-svn-id: http://svn.redmine.org/redmine/trunk@21068 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 465e79a09..a76ae9573 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -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)