goo blog サービス終了のお知らせ 

雑多な日々

ノンセクションで行こうかと思っています。

10/19時点の1.1.0に向けて開発中のredmineのガントチャートに日付を出力 その2

2010年10月20日 | Weblog
さて、r4262の続きです。
動き出したのはいいのですが、やっぱり、ガントチャートに日付がない。
では、ということで、自分で作ったパッチを当てるも、さすがにガントチャートのプログラムを書き変えただけはありましたね、パッチが当たりません。
画面上に日付はさっくり出せたのですが、PDFへの出力部が、どこで動作しているのかがなかなか見つからず、試行錯誤して、ようやく発見。
見つけた後は、ほぼほぼ、今までどおりの修正で日付は出力されました。
ま、これで、1.1.0がリリースされたときに、ガントチャートの日付がない!となっても、ほぼほぼ、なんとかなるかな。
ということで、unified diff。
今回はさすがに疲れましたよ…。
----
diff -ur redmine-trunk/app/views/gantts/show.html.erb redmine/app/views/gantts/show.html.erb
--- redmine-trunk/app/views/gantts/show.html.erb 2010-10-19 17:21:54.000000000 +0900
+++ redmine/app/views/gantts/show.html.erb 2010-10-19 15:54:33.000000000 +0900
@@ -47,6 +47,7 @@
 headers_height = header_heigth
 show_weeks = false
 show_days = false
+show_day_num = false
 
 if @gantt.zoom >1
     show_weeks = true
@@ -54,6 +55,10 @@
     if @gantt.zoom > 2
         show_days = true
         headers_height = 3*header_heigth
+        if @gantt.zoom > 3
+            show_day_num = true
+            headers_height = 4*header_heigth
+        end
     end
 end
 
@@ -130,6 +135,29 @@
  end
 end %>
 
+<%
+#
+# Days headers Num
+#
+if show_day_num
+    left = 0
+    height = g_height + header_heigth*2 - 1
+    wday = @gantt.date_from.cwday
+    day_num = @gantt.date_from
+    (@gantt.date_to - @gantt.date_from + 1).to_i.times do
+    width =  zoom - 1
+    %>
+    <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %><%= "color:blue;" if wday == 6 %><%= "color:red;" if wday == 7 %>" class="gantt_hdr">
+    <%= day_num.day %>
+    </div>
+    <%
+    left = left + width+1
+    day_num = day_num + 1
+    wday = wday + 1
+    wday = 1 if wday > 7
+    end
+end %>
+
 <% 
 #
 # Days headers
@@ -137,11 +165,12 @@
 if show_days
  left = 0
  height = g_height + header_heigth - 1
+        top = (show_day_num ? 55 : 37)
  wday = @gantt.date_from.cwday
  (@gantt.date_to - @gantt.date_from + 1).to_i.times do 
  width =  zoom - 1
  %>
- <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
+        <div style="left:<%= left %>px;top:<%= top %>px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %><%= "color:blue;" if wday == 6 %><%= "color:red;" if wday == 7 %>" class="gantt_hdr">
  <%= day_name(wday).first %>
  </div>
  <% 
diff -ur redmine-trunk/lib/redmine/helpers/gantt.rb redmine/lib/redmine/helpers/gantt.rb
--- redmine-trunk/lib/redmine/helpers/gantt.rb 2010-10-19 17:21:54.000000000 +0900
+++ redmine/lib/redmine/helpers/gantt.rb 2010-10-19 16:55:56.000000000 +0900
@@ -719,7 +719,7 @@
             else
               options[:pdf].SetX(options[:subject_width])
             end
-            options[:pdf].Cell(30, 2, "#{issue.status} #{issue.done_ratio}%")
+            options[:pdf].Cell(30, 2, "#{issue.status} #{issue.done_ratio}% (#{issue.assigned_to})")
           end
         else
           ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before"
@@ -851,7 +851,7 @@
         pdf.SetX(15)
         pdf.Cell(PDF::LeftPaneWidth, 20, project.to_s)
         pdf.Ln
-        pdf.SetFontStyle('B',9)
+        pdf.SetFontStyle('B',8)
         
         subject_width = PDF::LeftPaneWidth
         header_heigth = 5
@@ -859,13 +859,15 @@
         headers_heigth = header_heigth
         show_weeks = false
         show_days = false
+        show_day_num = false
         
         if self.months < 7
           show_weeks = true
           headers_heigth = 2*header_heigth
           if self.months < 3
             show_days = true
-            headers_heigth = 3*header_heigth
+            show_day_num = true
+            headers_heigth = 4*header_heigth
           end
         end
         
@@ -920,15 +922,26 @@
           left = subject_width
           height = header_heigth
           wday = self.date_from.cwday
-          pdf.SetFontStyle('B',7)
+          day_num = self.date_from
+          pdf.SetFontStyle('B',6)
           (self.date_to - self.date_from + 1).to_i.times do 
             width = zoom
+            if wday == 6
+              pdf.SetTextColor(0,0,255)
+            elsif wday == 7
+              pdf.SetTextColor(255,0,0)
+            end
             pdf.SetY(y_start + 2 * header_heigth)
             pdf.SetX(left)
+            pdf.Cell(width, height, day_num.day.to_s, "LTR", 0, "C")
+            pdf.SetY(y_start + 3 * header_heigth)
+            pdf.SetX(left)
             pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C")
             left = left + width
+            day_num = day_num + 1
             wday = wday + 1
             wday = 1 if wday > 7
+            pdf.SetTextColor(0,0,0)
           end
         end
         
----

最新の画像もっと見る

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。