diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 410e24847..30a8dba1f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -420,12 +420,8 @@ class ProjectsController < ApplicationController # Show changelog for @project def changelog @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') - if request.get? - @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } - else - @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array - end - @selected_tracker_ids ||= [] + retrieve_selected_tracker_ids(@trackers) + @fixed_issues = @project.issues.find(:all, :include => [ :fixed_version, :status, :tracker ], :conditions => [ "#{IssueStatus.table_name}.is_closed=? and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}) and #{Issue.table_name}.fixed_version_id is not null", true], @@ -436,12 +432,8 @@ class ProjectsController < ApplicationController def roadmap @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') - if request.get? - @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } - else - @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array - end - @selected_tracker_ids ||= [] + retrieve_selected_tracker_ids(@trackers) + @versions = @project.versions.find(:all, :conditions => [ "#{Version.table_name}.effective_date>?", Date.today], :order => "#{Version.table_name}.effective_date ASC" @@ -534,6 +526,9 @@ class ProjectsController < ApplicationController end def calendar + @trackers = Tracker.find(:all, :order => 'position') + retrieve_selected_tracker_ids(@trackers) + if params[:year] and params[:year].to_i > 1900 @year = params[:year].to_i if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 @@ -548,18 +543,24 @@ class ProjectsController < ApplicationController # start on monday @date_from = @date_from - (@date_from.cwday-1) # finish on sunday - @date_to = @date_to + (7-@date_to.cwday) - - @issues = @project.issues.find(:all, :include => [:tracker, :status, :assigned_to, :priority], - :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to]) - + @date_to = @date_to + (7-@date_to.cwday) + + @issues = @project.issues.find(:all, + :include => [:tracker, :status, :assigned_to, :priority], + :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] + ) unless @selected_tracker_ids.empty? + @issues ||=[] + @ending_issues_by_days = @issues.group_by {|issue| issue.due_date} @starting_issues_by_days = @issues.group_by {|issue| issue.start_date} - + render :layout => false if request.xhr? end def gantt + @trackers = Tracker.find(:all, :order => 'position') + retrieve_selected_tracker_ids(@trackers) + if params[:year] and params[:year].to_i >0 @year_from = params[:year].to_i if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 @@ -577,7 +578,13 @@ class ProjectsController < ApplicationController @date_from = Date.civil(@year_from, @month_from, 1) @date_to = (@date_from >> @months) - 1 - @issues = @project.issues.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)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]) + + @issues = @project.issues.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? + @issues ||=[] if params[:output]=='pdf' @options_for_rfpdf ||= {} @@ -630,6 +637,14 @@ private render_404 end + def retrieve_selected_tracker_ids(selectable_trackers) + if ids = params[:tracker_ids] + @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } + else + @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } + end + end + # Retrieve query from session or build a new query def retrieve_query if params[:query_id] diff --git a/app/views/projects/calendar.rhtml b/app/views/projects/calendar.rhtml index 8db92a938..23aba7d76 100644 --- a/app/views/projects/calendar.rhtml +++ b/app/views/projects/calendar.rhtml @@ -1,29 +1,39 @@
+ | <%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), - {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) }}, - {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1))} + {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids }}, + {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids)} %> | -+ | <%= select_month(@month, :prefix => "month", :discard_type => true) %> <%= select_year(@year, :prefix => "year", :discard_type => true) %> <%= submit_tag l(:button_submit), :class => "button-small" %> | -+ | + <%= l(:label_options) %> + + | +<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), - {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) }}, - {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1))} + {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids }}, + {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids)} %> |
-<% form_tag do %>
- - -<%= l(:label_months_from) %> -<%= select_month(@month_from, :prefix => "month", :discard_type => true) %> -<%= select_year(@year_from, :prefix => "year", :discard_type => true) %> -<%= hidden_field_tag 'zoom', @zoom %> -<%= submit_tag l(:button_submit), :class => "button-small" %> - -<% end %> + + <%= l(:label_months_from) %> + <%= select_month(@month_from, :prefix => "month", :discard_type => true) %> + <%= select_year(@year_from, :prefix => "year", :discard_type => true) %> + <%= hidden_field_tag 'zoom', @zoom %> + <%= submit_tag l(:button_submit), :class => "button-small" %> + |
++ <%= l(:label_options) %> + | <%= if @zoom < 4 - link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months} + link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids} else image_tag 'zoom_in_g.png' end %> <%= if @zoom > 1 - link_to image_tag('zoom_out.png'), :zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months + link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids} else image_tag 'zoom_out_g.png' end %> |
-
+
<%
#
# Tasks subjects
#
-top = headers_heigth + 8
+top = headers_height + 8
@issues.each do |i| %>
-
-<% top = top + 20
+
+ <% top = top + 20
end %>
|
-
|