From 6a3236daea38f0cf8b62ccf9f1212eb0f0395b08 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 27 Apr 2008 08:20:53 +0000 Subject: Include subprojects versions on calendar and gantt (#1116). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1364 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 6 ++++-- app/models/project.rb | 8 +++++--- app/views/common/_calendar.rhtml | 7 +++++-- app/views/projects/gantt.rhtml | 10 +++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8bdcea8d7..b71ec1ecd 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -341,8 +341,9 @@ class ProjectsController < ApplicationController :include => [:tracker, :status, :assigned_to, :priority, :project], :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] ) unless @selected_tracker_ids.empty? + events += Version.find(:all, :include => :project, + :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) end - events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) @calendar.events = events render :layout => false if request.xhr? @@ -386,8 +387,9 @@ class ProjectsController < ApplicationController :include => [:tracker, :status, :assigned_to, :priority, :project], :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_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? + @events += Version.find(:all, :include => :project, + :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) end - @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[:format]=='pdf' diff --git a/app/models/project.rb b/app/models/project.rb index eaa33c969..964469649 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -75,12 +75,14 @@ class Project < ActiveRecord::Base conditions = nil if include_subprojects && !active_children.empty? ids = [id] + active_children.collect {|c| c.id} - conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"] + conditions = ["#{Project.table_name}.id IN (#{ids.join(',')})"] end - conditions ||= ["#{Issue.table_name}.project_id = ?", id] + conditions ||= ["#{Project.table_name}.id = ?", id] # Quick and dirty fix for Rails 2 compatibility Issue.send(:with_scope, :find => { :conditions => conditions }) do - yield + Version.send(:with_scope, :find => { :conditions => conditions }) do + yield + end end end diff --git a/app/views/common/_calendar.rhtml b/app/views/common/_calendar.rhtml index 7534a1223..1095cd501 100644 --- a/app/views/common/_calendar.rhtml +++ b/app/views/common/_calendar.rhtml @@ -19,12 +19,15 @@ while day <= calendar.enddt %> elsif day == i.due_date image_tag('arrow_to.png') end %> - <%= h("#{i.project.name} -") unless @project && @project == i.project %> + <%= h("#{i.project} -") unless @project && @project == i.project %> <%= link_to_issue i %>: <%= h(truncate(i.subject, 30)) %> <%= render_issue_tooltip i %> <% else %> - <%= link_to_version i, :class => "icon icon-package" %> + + <%= h("#{i.project} -") unless @project && @project == i.project %> + <%= link_to_version i%> + <% end %> <% end %> diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml index 05bd4b9bc..d941d2777 100644 --- a/app/views/projects/gantt.rhtml +++ b/app/views/projects/gantt.rhtml @@ -70,10 +70,13 @@ top = headers_height + 8 @events.each do |i| %>
<% if i.is_a? Issue %> - <%= h("#{i.project.name} -") unless @project && @project == i.project %> + <%= h("#{i.project} -") unless @project && @project == i.project %> <%= link_to_issue i %>: <%=h i.subject %> <% else %> - <%= link_to_version i, :class => "icon icon-package" %> + + <%= h("#{i.project} -") unless @project && @project == i.project %> + <%= link_to_version i %> + <% end %>
<% top = top + 20 @@ -197,7 +200,8 @@ top = headers_height + 10 %>
 
- <%= i.name %> + <%= h("#{i.project} -") unless @project && @project == i.project %> + <%=h i %>
<% end %> <% top = top + 20 -- cgit v1.2.3