Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Redmine 3.3.1 #7

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Assignee column and some preferences for Gantt chart.
![Progressive Gantt Mods Screenshot](http://stgeneral.github.io/redmine-progressive-gantt-mods/images/progressive_gantt_mods-screen-en.png)


Compatible with [Redmine](http://www.redmine.org/) 2.4.
Compatible with [Redmine](http://www.redmine.org/) 3.3.1.

Other Proressive plugins for Redmine
------------------------------------
Expand Down
106 changes: 100 additions & 6 deletions app/views/gantts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end
%>

<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
<h2><%= @query.new_record? ? l(:label_gantt) : @query.name %></h2>

<%= form_tag({:controller => 'gantts', :action => 'show',
:project_id => @project, :month => params[:month],
Expand All @@ -37,7 +37,7 @@
<%= render :partial => 'queries/filters', :locals => {:query => @query} %>
</div>
</fieldset>
<fieldset class="collapsible collapsed">
<fieldset id="options" class="collapsible collapsed">
<legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
<div style="display: none;">
<table>
Expand Down Expand Up @@ -108,13 +108,18 @@
headers_height = header_height
show_weeks = false
show_days = false
show_day_num = false

if @gantt.zoom > 1
show_weeks = true
headers_height = 2 * header_height
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

Expand All @@ -137,6 +142,58 @@

<table style="width:100%; border:0; border-collapse: collapse;">
<tr>
<%
line_number_width = @gantt.number_of_rows.to_s.length * 8 + 8
%>
<td style="width:<%= line_number_width %>px; padding:0px;">
<%
style = ""
style += "position:relative;"
style += "height: #{t_height + 24}px;"
style += "width: #{line_number_width + 1}px;"
%>
<%= content_tag(:div, :style => style) do %>
<%
style = ""
style += "right: -2px;"
style += "width: #{line_number_width}px;"
style += "height: #{headers_height}px;"
style += "line-height: #{headers_height}px;"
style += "font-size:0.9em;"
style += 'background: #eee;'
%>
<%= content_tag(:div, "LN", :style => style, :class => "gantt_hdr") %>
<%
style = ""
style += "right: -2px;"
style += "width: #{line_number_width}px;"
style += "height: #{t_height}px;"
style += 'border-left: 1px solid #c0c0c0;'
style += 'overflow: hidden;'
%>
<%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
<%
top = headers_height + 9
line_number = 1
%>
<% @gantt.number_of_rows.times do %>
<%
style = ""
style += "right: +4px;"
style += "top: #{top}px;"
style += "position: absolute;"
%>
<%= content_tag(:div, :style => style, :class => "gantt_subjects") do %>
<%= line_number %>
<% end %>
<%
top = top + 20
line_number = line_number + 1
%>
<% end %>
<% end %>
</td>

<td style="width:<%= subject_width %>px; padding:0px;">
<%
style = ""
Expand Down Expand Up @@ -226,7 +283,7 @@
style += "height: #{height}px;"
%>
<%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
<%= link_to h("#{month_f.year}-#{month_f.month}"),
<%= link_to "#{month_f.year}-#{month_f.month}",
@gantt.params.merge(:year => month_f.year, :month => month_f.month),
:title => "#{month_name(month_f.month)} #{month_f.year}" %>
<% end %>
Expand Down Expand Up @@ -285,25 +342,62 @@
<% 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)
%>
<% if wday == 6 %><% style += "color:blue;" %><% end %>
<% if wday == 7 %><% style += "color:red;" %><% end %>
<%= 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;"
clss = "gantt_hdr"
clss << " nwday" if @gantt.non_working_week_days.include?(wday)
%>
<% if wday == 6 %><% style += "color:blue;" %><% end %>
<% if wday == 7 %><% style += "color:red;" %><% end %>
<%= content_tag(:div, :style => style, :class => clss) do %>
<%= day_letter(wday) %>
<% end %>
Expand All @@ -318,9 +412,9 @@
<%= @gantt.lines.html_safe %>

<% ###### Today red line (excluded from cache) ###### %>
<% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
<% if User.current.today >= @gantt.date_from and User.current.today <= @gantt.date_to %>
<%
today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
today_left = (((User.current.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
style = ""
style += "position: absolute;"
style += "height: #{g_height}px;"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
en:
setting_show_subject_lines: Show subjects at right
setting_show_assignees: Show assignees column
setting_subject_width: Subject conlumn width
setting_subject_width: Subject column width
setting_assignee_width: Assignee column width
5 changes: 5 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ja:
setting_show_subject_lines: 題名を右に表示
setting_show_assignees: 担当者列を表示
setting_subject_width: 題名列の幅
setting_assignee_width: 担当者列の幅
5 changes: 5 additions & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zh:
setting_show_subject_lines: 在右侧显示主题
setting_show_assignees: 显示【指派给】列
setting_subject_width: 【主题】列宽
setting_assignee_width: 【指派给】列宽
44 changes: 16 additions & 28 deletions lib/progressive/gantt_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,31 @@ def initialize_with_assignees(options={})
@assignees = ''
end

def render_issues_with_assignees(issues, options={})
@issue_ancestors = []
issues.each do |i|
subject_for_issue(i, options) unless options[:only] == :lines
assignee_for_issue(i, options)
line_for_issue(i, options) unless options[:only] == :subjects
options[:top] += options[:top_increment]
@number_of_rows += 1
break if abort?
def render_object_row_with_assignees(object, options)
class_name = object.class.name.downcase
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines
send("assignee_for_#{class_name}", object, options) unless "#{class_name}" != "issue"
send("line_for_#{class_name}", object, options) unless options[:only] == :subjects
options[:top] += options[:top_increment]
@number_of_rows += 1
if @max_rows && @number_of_rows >= @max_rows
raise MaxLinesLimitReached
end
options[:indent] -= (options[:indent_increment] * @issue_ancestors.size)
end

def line_for_issue_with_subject(issue, options)
# Skip issues that don't have a due_before (due_date or version's due_date)
if issue.is_a?(Issue) && (issue.due_before || options[:show_subject_lines])
coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom])
label = "#{issue.status.name} #{issue.done_ratio}%"
case options[:format]
when :html
label += " - #{issue.subject}" if options[:show_subject_lines]
html_task(options, coords,
:css => "task " + (issue.leaf? ? 'leaf' : 'parent'),
:label => label, :issue => issue,
:markers => !issue.leaf?)
when :image
image_task(options, coords, :label => label)
when :pdf
pdf_task(options, coords, :label => label)
end
else
''
label += " - #{issue.subject}" if options[:show_subject_lines]
markers = !issue.leaf?
line(issue.start_date, issue.due_before, issue.done_ratio, markers, label, options, issue)
end
end

alias_method_chain :initialize, :assignees
alias_method_chain :render_issues, :assignees
alias_method_chain :line_for_issue, :subject
alias_method_chain :initialize, :assignees
alias_method_chain :render_object_row, :assignees
alias_method_chain :line_for_issue, :subject

# Renders the subjects of the Gantt chart, the left side.
def assignees(options={})
Expand Down