Skip to content

Instantly share code, notes, and snippets.

@hatak
Created May 29, 2015 06:10
Show Gist options
  • Save hatak/5364e61c54523a2b2e89 to your computer and use it in GitHub Desktop.
Save hatak/5364e61c54523a2b2e89 to your computer and use it in GitHub Desktop.
patch for displaying days in gantt chart of Redmine
diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb
index f8f25be..80884c6 100644
--- a/app/views/gantts/show.html.erb
+++ b/app/views/gantts/show.html.erb
@@ -76,12 +76,17 @@
headers_height = header_height
show_weeks = false
+ show_week_day_top = false
show_days = false
+ show_day_num = false
if @gantt.zoom > 1
show_weeks = true
+ show_week_day_top = true
headers_height = 2 * header_height
if @gantt.zoom > 2
+ show_week_day_top = false
+ show_day_num = true
show_days = true
headers_height = 3 * header_height
end
@@ -170,7 +175,7 @@
<% end %>
<% ###### Weeks headers ###### %>
-<% if show_weeks %>
+<% if show_week_day_top %>
<%
left = 0
height = (show_days ? header_height - 1 : header_height - 1 + g_height)
@@ -208,7 +213,7 @@
%>
<%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
<%= content_tag(:small) do %>
- <%= week_f.cweek if width >= 16 %>
+ <%= week_f.day if width >= 16 %>
<% end %>
<% end %>
<%
@@ -218,6 +223,28 @@
<% end %>
<% end %>
+<% ###### Days Num headers ###### %>
+<% if show_day_num %>
+ <%
+ left = 0
+ height = g_height + header_height + 17
+ 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:19px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" 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 ####### %>
<% if show_days %>
<%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment