]> source.dussan.org Git - redmine.git/commitdiff
Added versions due dates on gantt chart.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Apr 2007 12:09:01 +0000 (12:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Apr 2007 12:09:01 +0000 (12:09 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@428 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/models/version.rb
app/views/projects/gantt.rfpdf
app/views/projects/gantt.rhtml
public/stylesheets/application.css

index 80855889a07dd9d8efeec3b17d3654247591e681..0cbc6b5a72e96415231def4f94c49364b9ca4037 100644 (file)
@@ -592,14 +592,16 @@ class ProjectsController < ApplicationController
     @date_from = Date.civil(@year_from, @month_from, 1)
     @date_to = (@date_from >> @months) - 1
     
+    @events = []
     @project.issues_with_subprojects(params[:with_subprojects]) do
-      @issues = Issue.find(:all, 
+      @events += Issue.find(:all, 
                            :order => "start_date, due_date",
                            :include => [:tracker, :status, :assigned_to, :priority], 
                            :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
                            ) unless @selected_tracker_ids.empty?
     end
-    @issues ||=[]
+    @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
+    @events.sort! {|x,y| x.start_date <=> y.start_date }
     
     if params[:output]=='pdf'
       @options_for_rfpdf ||= {}
index 611500c8c93aa19bdefecf81c2dae7287f4266ec..ddae037a66057a261e589d85b7e5dbd03c2b67ee 100644 (file)
@@ -25,6 +25,14 @@ class Version < ActiveRecord::Base
   validates_uniqueness_of :name, :scope => [:project_id]
   validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
   
+  def start_date
+    effective_date
+  end
+  
+  def due_date
+    effective_date
+  end
+  
 private
   def check_integrity
     raise "Can't delete version" if self.fixed_issues.find(:first)
index 6f85ce742b5f8ac24e1b03cd1aed9295d63d04ee..f5e64b1b3bd34efc37402fd44d349129a6039945 100644 (file)
@@ -106,51 +106,70 @@ pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
 #\r
 top = headers_heigth + y_start\r
 pdf.SetFontStyle('B',7)\r
-@issues.each do |i|\r
+@events.each do |i|\r
        pdf.SetY(top)\r
        pdf.SetX(15)\r
-       pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")\r
+       \r
+       if i.is_a? Issue\r
+               pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")\r
+       else\r
+               pdf.Cell(subject_width-15, 5, "#{l(:label_version)}: #{i.name}", "LR")\r
+       end\r
 \r
        pdf.SetY(top)\r
        pdf.SetX(subject_width)\r
        pdf.Cell(g_width, 5, "", "LR")\r
+\r
+       pdf.SetY(top+1.5)\r
        \r
-       i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )\r
-       i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )\r
-       \r
-       i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor\r
-       i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )\r
-       i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )\r
+       if i.is_a? Issue\r
+               i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )\r
+               i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )\r
+               \r
+               i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor\r
+               i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )\r
+               i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )\r
+               \r
+               i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today\r
+               \r
+               i_left = ((i_start_date - @date_from)*zoom) \r
+               i_width = ((i_end_date - i_start_date + 1)*zoom)\r
+               d_width = ((i_done_date - i_start_date)*zoom)\r
+               l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date\r
+               l_width ||= 0\r
        \r
-       i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today\r
+               pdf.SetX(subject_width + i_left)\r
+               pdf.SetFillColor(200,200,200)\r
+               pdf.Cell(i_width, 2, "", 0, 0, "", 1)\r
        \r
-       i_left = ((i_start_date - @date_from)*zoom) \r
-       i_width = ((i_end_date - i_start_date + 1)*zoom)\r
-       d_width = ((i_done_date - i_start_date)*zoom)\r
-       l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date\r
-       l_width ||= 0\r
-\r
-       pdf.SetY(top+1.5)\r
-       pdf.SetX(subject_width + i_left)\r
-       pdf.SetFillColor(200,200,200)\r
-       pdf.Cell(i_width, 2, "", 0, 0, "", 1)\r
-\r
-       if l_width > 0\r
+               if l_width > 0\r
+                       pdf.SetY(top+1.5)\r
+                       pdf.SetX(subject_width + i_left)\r
+                       pdf.SetFillColor(255,100,100)\r
+                       pdf.Cell(l_width, 2, "", 0, 0, "", 1)\r
+               end \r
+               if d_width > 0\r
+                       pdf.SetY(top+1.5)\r
+                       pdf.SetX(subject_width + i_left)\r
+                       pdf.SetFillColor(100,100,255)\r
+                       pdf.Cell(d_width, 2, "", 0, 0, "", 1)\r
+               end\r
+               \r
                pdf.SetY(top+1.5)\r
+               pdf.SetX(subject_width + i_left + i_width)\r
+               pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")\r
+       else\r
+               i_left = ((i.start_date - @date_from)*zoom) \r
+               \r
                pdf.SetX(subject_width + i_left)\r
-               pdf.SetFillColor(255,100,100)\r
-               pdf.Cell(l_width, 2, "", 0, 0, "", 1)\r
-       end \r
-       if d_width > 0\r
+               pdf.SetFillColor(50,200,50)\r
+               pdf.Cell(2, 2, "", 0, 0, "", 1) \r
+\r
                pdf.SetY(top+1.5)\r
-               pdf.SetX(subject_width + i_left)\r
-               pdf.SetFillColor(100,100,255)\r
-               pdf.Cell(d_width, 2, "", 0, 0, "", 1)\r
+               pdf.SetX(subject_width + i_left + 3)\r
+               pdf.Cell(30, 2, "#{i.name}")\r
        end\r
        \r
-       pdf.SetY(top+1.5)\r
-       pdf.SetX(subject_width + i_left + i_width)\r
-       pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")\r
        \r
        top = top + 5\r
        pdf.SetDrawColor(200, 200, 200)\r
index 8c6c5b63520a935814f974cbb9e126b1ce3f8286..4a10a7b4c2bcfd78aa146789c54e72bb45e558d8 100644 (file)
@@ -67,7 +67,7 @@ if @zoom >1
 end
 
 g_width = (@date_to - @date_from + 1)*zoom
-g_height = [(20 * @issues.length + 6)+150, 206].max
+g_height = [(20 * @events.length + 6)+150, 206].max
 t_height = g_height + headers_height
 %>
 
@@ -83,11 +83,15 @@ t_height = g_height + headers_height
 # Tasks subjects
 #
 top = headers_height + 8
-@issues.each do |i| %>
-    <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;">
-       <small><%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
-       <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small>
-       </div>
+@events.each do |i| %>
+    <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>    
+    <% if i.is_a? Issue %>
+       <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
+       <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %>
+       <% else %>
+       <strong><%= "#{l(:label_version)}: #{i.name}" %></strong>
+       <% end %>       
+       </small></div>
     <% top = top + 20
 end %>
 </div>
@@ -180,8 +184,8 @@ if Date.today >= @date_from and Date.today <= @date_to %>
 # Tasks
 #
 top = headers_height + 10
-@issues.each do |i| %>
-       <%
+@events.each do |i| 
+  if i.is_a? Issue 
        i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
        i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
        
@@ -212,6 +216,14 @@ top = headers_height + 10
        <span class="tip">
     <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
        </span></div>
+<% else 
+    i_left = ((i.start_date - @date_from)*zoom).floor
+    %>
+    <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
+       <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
+       <strong><%= i.name %></strong>
+       </div>
+<% end %>
        <% top = top + 20
 end %>
 </div>
index 185cfa87eab61f3235ef6320b9079fc41ff583ea..97ac05b71c1d7940b9453c309276c3380915a310 100644 (file)
@@ -559,6 +559,7 @@ font-size: 1em;
 .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
 .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }  
 .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
+.milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; }
 
 /***** Tooltips ******/
 .tooltip{position:relative;z-index:24;}