]> source.dussan.org Git - redmine.git/commitdiff
Adds day numbers to HTML and PDF gantt (#3034).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 3 Oct 2015 09:10:27 +0000 (09:10 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 3 Oct 2015 09:10:27 +0000 (09:10 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14638 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/gantts/show.html.erb
lib/redmine/helpers/gantt.rb
public/stylesheets/application.css

index ada60cd668e8883cd62495480ba541b732138257..dc89b2090df3042d0a69a801fcfe0b08d5b0e2e8 100644 (file)
@@ -90,6 +90,7 @@
   headers_height = header_height
   show_weeks = false
   show_days  = false
+  show_day_num = false
 
   if @gantt.zoom > 1
     show_weeks = true
     if @gantt.zoom > 2
         show_days = true
         headers_height = 3 * header_height
+        if @gantt.zoom > 3
+          show_day_num = true
+          headers_height = 4 * header_height
+        end
     end
   end
 
   <% end %>
 <% end %>
 
+<% ###### Day numbers headers ###### %>
+<% if show_day_num %>
+  <%
+    left = 0
+    height = g_height + header_height*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
+      style = ""
+      style += "left:#{left}px;"
+      style += "top:37px;"
+      style += "width:#{width}px;"
+      style += "height:#{height}px;"
+      style += "font-size:0.7em;"
+      clss = "gantt_hdr"
+      clss << " nwday" if @gantt.non_working_week_days.include?(wday)
+    %>
+    <%= content_tag(:div, :style => style, :class => clss) do %>
+      <%= day_num.day %>
+    <% end %>
+    <%
+     left = left + width+1
+     day_num = day_num + 1
+     wday = wday + 1
+     wday = 1 if wday > 7
+    %>
+  <% end %>
+<% end %> 
+
 <% ###### Days headers ####### %>
 <% if show_days %>
   <%
     left = 0
     height = g_height + header_height - 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
       style  = ""
       style += "left: #{left}px;"
-      style += "top:37px;"
+      style += "top: #{top}px;"
       style += "width: #{width}px;"
       style += "height: #{height}px;"
       style += "font-size:0.7em;"
index f2342efeb5dad9a7e3b82a4ad57805247d291ed7..d551112a140a1fdd47fa365892bb8050eed75943 100644 (file)
@@ -460,6 +460,10 @@ module Redmine
           if self.months < 3
             show_days = true
             headers_height = 3 * header_height
+            if self.months < 2
+              show_day_num = true
+              headers_height = 4 * header_height
+            end
           end
         end
         g_width = PDF.right_pane_width
@@ -504,6 +508,25 @@ module Redmine
             week_f = week_f + 7
           end
         end
+        # Day numbers headers
+        if show_day_num
+          left = subject_width
+          height = header_height
+          day_num = self.date_from
+          wday = self.date_from.cwday
+          pdf.SetFontStyle('B', 7)
+          (self.date_to - self.date_from + 1).to_i.times do
+            width = zoom
+            pdf.SetY(y_start + header_height * 2)
+            pdf.SetX(left)
+            pdf.SetTextColor(non_working_week_days.include?(wday) ? 150 : 0)
+            pdf.RDMCell(width, height, day_num.day.to_s, "LTR", 0, "C")
+            left = left + width
+            day_num = day_num + 1
+            wday = wday + 1
+            wday = 1 if wday > 7
+          end
+        end
         # Days headers
         if show_days
           left = subject_width
@@ -512,8 +535,9 @@ module Redmine
           pdf.SetFontStyle('B', 7)
           (self.date_to - self.date_from + 1).to_i.times do
             width = zoom
-            pdf.SetY(y_start + 2 * header_height)
+            pdf.SetY(y_start + header_height * (show_day_num ? 3 : 2))
             pdf.SetX(left)
+            pdf.SetTextColor(non_working_week_days.include?(wday) ? 150 : 0)
             pdf.RDMCell(width, height, day_name(wday).first, "LTR", 0, "C")
             left = left + width
             wday = wday + 1
@@ -522,6 +546,7 @@ module Redmine
         end
         pdf.SetY(y_start)
         pdf.SetX(15)
+        pdf.SetTextColor(0)
         pdf.RDMCell(subject_width + g_width - 15, headers_height, "", 1)
         # Tasks
         top = headers_height + y_start
index 3047f2fab21fee22fcbd67f5c44caed0ffe04c90..4a66774a2985d476f813d84856a39501c936a3aa 100644 (file)
@@ -967,7 +967,7 @@ a.close-icon:hover {background-image:url('../images/close_hl.png');}
   overflow: hidden;
 }
 
-.gantt_hdr.nwday {background-color:#f1f1f1;}
+.gantt_hdr.nwday {background-color:#f1f1f1; color:#999;}
 
 .gantt_subjects { font-size: 0.8em; }
 .gantt_subjects div { line-height:16px;height:16px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis; }