##// END OF EJS Templates
Added the ability to include subprojects issues on calendar & gantt (options box)...
Jean-Philippe Lang -
r395:0a82489ddcc2
parent child
Show More
@@ -545,10 +545,12 class ProjectsController < ApplicationController
545 # finish on sunday
545 # finish on sunday
546 @date_to = @date_to + (7-@date_to.cwday)
546 @date_to = @date_to + (7-@date_to.cwday)
547
547
548 @issues = @project.issues.find(:all,
548 @project.issues_with_subprojects(params[:with_subprojects]) do
549 :include => [:tracker, :status, :assigned_to, :priority],
549 @issues = Issue.find(:all,
550 :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
550 :include => [:tracker, :status, :assigned_to, :priority],
551 ) unless @selected_tracker_ids.empty?
551 :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
552 ) unless @selected_tracker_ids.empty?
553 end
552 @issues ||=[]
554 @issues ||=[]
553
555
554 @ending_issues_by_days = @issues.group_by {|issue| issue.due_date}
556 @ending_issues_by_days = @issues.group_by {|issue| issue.due_date}
@@ -579,11 +581,13 class ProjectsController < ApplicationController
579 @date_from = Date.civil(@year_from, @month_from, 1)
581 @date_from = Date.civil(@year_from, @month_from, 1)
580 @date_to = (@date_from >> @months) - 1
582 @date_to = (@date_from >> @months) - 1
581
583
582 @issues = @project.issues.find(:all,
584 @project.issues_with_subprojects(params[:with_subprojects]) do
583 :order => "start_date, due_date",
585 @issues = Issue.find(:all,
584 :include => [:tracker, :status, :assigned_to, :priority],
586 :order => "start_date, due_date",
585 :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]
587 :include => [:tracker, :status, :assigned_to, :priority],
586 ) unless @selected_tracker_ids.empty?
588 :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]
589 ) unless @selected_tracker_ids.empty?
590 end
587 @issues ||=[]
591 @issues ||=[]
588
592
589 if params[:output]=='pdf'
593 if params[:output]=='pdf'
@@ -47,6 +47,19 class Project < ActiveRecord::Base
47 errors[:identifier].nil? && !(new_record? || identifier.blank?)
47 errors[:identifier].nil? && !(new_record? || identifier.blank?)
48 end
48 end
49
49
50 def issues_with_subprojects(include_subprojects=false)
51 conditions = nil
52 if include_subprojects && children.size > 0
53 ids = [id] + children.collect {|c| c.id}
54 conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"]
55 else
56 conditions = ["#{Issue.table_name}.project_id = ?", id]
57 end
58 Issue.with_scope :find => { :conditions => conditions } do
59 yield
60 end
61 end
62
50 # returns latest created projects
63 # returns latest created projects
51 # non public projects will be returned only if user is a member of those
64 # non public projects will be returned only if user is a member of those
52 def self.latest(user=nil, count=5)
65 def self.latest(user=nil, count=5)
@@ -5,8 +5,8
5 <tr>
5 <tr>
6 <td align="left" style="width:15%">
6 <td align="left" style="width:15%">
7 <%= link_to_remote ('&#171; ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")),
7 <%= link_to_remote ('&#171; ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")),
8 {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids }},
8 {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }},
9 {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids)}
9 {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])}
10 %>
10 %>
11 </td>
11 </td>
12 <td align="center" style="width:55%">
12 <td align="center" style="width:55%">
@@ -22,13 +22,17
22 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
22 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
23 <%= tracker.name %><br />
23 <%= tracker.name %><br />
24 <% end %>
24 <% end %>
25 <% if @project.children.any? %>
26 <p><strong><%=l(:label_subproject_plural)%></strong></p>
27 <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %>
28 <% end %>
25 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
29 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
26 </div>
30 </div>
27 </td>
31 </td>
28 <td align="right" style="width:15%">
32 <td align="right" style="width:15%">
29 <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' &#187;'),
33 <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' &#187;'),
30 {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids }},
34 {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }},
31 {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids)}
35 {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])}
32 %>&nbsp;
36 %>&nbsp;
33 </td>
37 </td>
34 </tr>
38 </tr>
@@ -1,6 +1,6
1 <div class="contextual">
1 <div class="contextual">
2 <%= l(:label_export_to) %>
2 <%= l(:label_export_to) %>
3 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :output => 'pdf'}, :class => 'icon icon-pdf' %>
3 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %>
4 </div>
4 </div>
5
5
6 <h2><%= l(:label_gantt) %></h2>
6 <h2><%= l(:label_gantt) %></h2>
@@ -24,17 +24,21
24 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
24 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
25 <%= tracker.name %><br />
25 <%= tracker.name %><br />
26 <% end %>
26 <% end %>
27 <% if @project.children.any? %>
28 <p><strong><%=l(:label_subproject_plural)%></strong></p>
29 <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %>
30 <% end %>
27 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
31 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
28 </div>
32 </div>
29 </td>
33 </td>
30 <td align="right">
34 <td align="right">
31 <%= if @zoom < 4
35 <%= if @zoom < 4
32 link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids}
36 link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
33 else
37 else
34 image_tag 'zoom_in_g.png'
38 image_tag 'zoom_in_g.png'
35 end %>
39 end %>
36 <%= if @zoom > 1
40 <%= if @zoom > 1
37 link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids}
41 link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
38 else
42 else
39 image_tag 'zoom_out_g.png'
43 image_tag 'zoom_out_g.png'
40 end %>
44 end %>
@@ -103,7 +107,7 height = (show_weeks ? header_heigth : header_heigth + g_height)
103 width = ((month_f >> 1) - month_f) * zoom - 1
107 width = ((month_f >> 1) - month_f) * zoom - 1
104 %>
108 %>
105 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
109 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
106 <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months }, :title => "#{month_name(month_f.month)} #{month_f.year}"%>
110 <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%>
107 </div>
111 </div>
108 <%
112 <%
109 left = left + width + 1
113 left = left + width + 1
@@ -217,7 +221,7 end %>
217
221
218 <table width="100%">
222 <table width="100%">
219 <tr>
223 <tr>
220 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids %></td>
224 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
221 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids %></td>
225 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
222 </tr>
226 </tr>
223 </table> No newline at end of file
227 </table>
General Comments 0
You need to be logged in to leave comments. Login now