プラグイン紹介 redmine_better_gantt_chart

使っているプラグインを紹介します。今回は redmine_better_gantt_chart です。
ガントチャートでチケット同士の関係を矢印でつないで表示したりソート順を改善するプラグインです。
redmine-2系にはまだ対応していないようですが redmine-2系対応fork版 というのを見つけました。
これは 2系対応以外にも日付表示などの機能追加が入っているようです。

ただしこの版は背景色がすべてグレイになるというバグがあったので修正しました。(2012-12-10 に更新されたバージョンに関してなので近いうちに直っているかもしれません)
ついでに年月の表示の変更と「土」「日」をそれぞれ青と赤で表示する変更も入れました。
その(本家ではなく redmine-2系対応fork版に対する)パッチです。

--- app/views/gantts/show.html.erb.org
+++ app/views/gantts/show.html.erb
@@ -355,6 +355,6 @@
   <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
     <%
-      month_title = month_f.strftime("%b")
-      month_title += " #{month_f.year}" unless show_years
+      month_title = month_f.month.to_s
+      month_title = "#{month_f.year}-" + month_title unless show_years
     %>
       <%= link_to h("#{month_title}"),
@@ -438,4 +438,6 @@
         style += "font-size:0.7em;"
         style += 'background:#f1f1f1;' if (@gantt.work_on_weekends && wday > 5)
+        style += 'color:blue;' if wday == 6
+        style += 'color:red;' if wday == 7
         style += 'border-left: 1px solid #c6c6c6;' if (!@gantt.work_on_weekends && wday == 1)
       %>
@@ -449,10 +451,7 @@
     <% end %>
     <%
-      if day.cwday <= work_days_in_week
-        left = left + width+1
-        wday = wday + 1
-      else
-        wday = 1
-      end
+      left = left + width+1 if day.cwday <= work_days_in_week
+      wday = wday + 1
+      wday = 1 if wday > 7
     %>
   <% end %>

さらについでに、Redmine のガントチャートでチケットを開始日順に表示する に書いたパッチもあてています。

--- lib/redmine/helpers/better_gantt.rb.org
+++ lib/redmine/helpers/better_gantt.rb
@@ -897,19 +897,12 @@
       def get_compare_params(issue)
         if RedmineBetterGanttChart.smart_sorting?
-          # Smart sorting: issues sorted first by start date of their parent issue, then by id of parent issue, then by start date
-
-          start_date = issue.start_date || Date.new()
-
-          if issue.leaf? && issue.parent.present?
-            identifying_id = issue.parent_id || issue.id
-            identifying_start = issue.parent.start_date || start_date
-            root_start = issue.root.start_date || start_date
-          else
-            identifying_id = issue.id
-            identifying_start = start_date
-            root_start = start_date
+          julian_date = Date.new()
+          ancesters_start_date = []
+          while (parent = issue.parent)
+            ancesters_start_date.unshift(issue.start_date || julian_date)
+            issue = parent
           end
-
-          [root_start, issue.root_id, identifying_start, start_date, issue.lft]
+          ancesters_start_date.unshift(issue.id)
+          ancesters_start_date
         else
           # Default Redmine sorting