Skip to content

Instantly share code, notes, and snippets.

@mikesorae
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesorae/c5d5c844ce7c8d0eb797 to your computer and use it in GitHub Desktop.
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.
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"
@mikesorae
Copy link
Author

Usage

  1. Create a custom field named "custom_subject" in the administration screen.
  2. Relate a custom field to your project
  3. Create a ticket that has a custom subject
  4. Display the gantt screen
  5. Toggle "use custom subject" checkbox on in the option pain
  6. Click a apply button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment