Last active
August 29, 2015 14:04
-
-
Save mikesorae/c5d5c844ce7c8d0eb797 to your computer and use it in GitHub Desktop.
this is the patch for redmine to display custom_subject in the gantt chart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb | |
index 62c6fbb..2467a66 100644 | |
--- a/app/helpers/application_helper.rb | |
+++ b/app/helpers/application_helper.rb | |
@@ -74,7 +74,12 @@ module ApplicationHelper | |
if options[:subject] == false | |
title = issue.subject.truncate(60) | |
else | |
- subject = issue.subject | |
+ if options[:use_custom_subject] | |
+ subject = issue.custom_field_values.detect{|cf| cf.custom_field.name == "custom_subject"}.try(:value) | |
+ else | |
+ subject = issue.subject | |
+ end | |
+ | |
if truncate_length = options[:truncate] | |
subject = subject.truncate(truncate_length) | |
end | |
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb | |
index 5490585..b920890 100644 | |
--- a/app/models/issue_query.rb | |
+++ b/app/models/issue_query.rb | |
@@ -89,6 +89,17 @@ class IssueQuery < Query | |
end | |
end | |
+ def use_custom_subject | |
+ r = options[:use_custom_subject] | |
+ r == '1' | |
+ end | |
+ | |
+ def use_custom_subject=(arg) | |
+ puts :use_custom_subject= | |
+ puts arg | |
+ options[:use_custom_subject] = (arg == '1' ? '1' : nil) | |
+ end | |
+ | |
def is_private? | |
visibility == VISIBILITY_PRIVATE | |
end | |
@@ -119,6 +130,7 @@ class IssueQuery < Query | |
super | |
self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations]) | |
self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line]) | |
+ self.use_custom_subject = params[:use_custom_subject] || (params[:query] && params[:query][:use_custom_subject]) | |
self | |
end | |
diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb | |
index 83fcd89..e84ee44 100644 | |
--- a/app/views/gantts/show.html.erb | |
+++ b/app/views/gantts/show.html.erb | |
@@ -49,6 +49,15 @@ | |
</label> | |
</fieldset> | |
</td> | |
+ <td> | |
+ <fieldset> | |
+ <legend><%= "use custom subject" %></legend> | |
+ <label for="use_custom_subject"> | |
+ <%= check_box 'query', 'use_custom_subject', :id => 'use_custom_subject' %> | |
+ <%= "use custom subject" %> | |
+ </label> | |
+ </fieldset> | |
+ </td> | |
</tr> | |
</table> | |
</div> | |
@@ -105,7 +114,9 @@ | |
@gantt.render(:top => headers_height + 8, | |
:zoom => zoom, | |
:g_width => g_width, | |
- :subject_width => subject_width) | |
+ :subject_width => subject_width, | |
+ :use_custom_subject => @query.use_custom_subject | |
+ ) | |
g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max | |
t_height = g_height + headers_height | |
%> | |
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb | |
index f8990d4..bfe21ae 100644 | |
--- a/lib/redmine/helpers/gantt.rb | |
+++ b/lib/redmine/helpers/gantt.rb | |
@@ -380,7 +380,7 @@ module Redmine | |
:size => 10, | |
:title => assigned_string).to_s.html_safe | |
end | |
- s << view.link_to_issue(issue).html_safe | |
+ s << view.link_to_issue(issue, options).html_safe | |
subject = view.content_tag(:span, s, :class => css_classes).html_safe | |
html_subject(options, subject, :css => "issue-subject", | |
:title => issue.subject, :id => "issue-#{issue.id}") + "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage