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 (separated PR) #8

Open
wants to merge 2 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
50 changes: 44 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 Down Expand Up @@ -226,7 +231,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,19 +290,52 @@
<% 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;"
Expand All @@ -318,9 +356,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
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