Patch #9705 Tracker filtering on Main Calendar (Jeffrey Jones)

Slightly edited.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@395 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-03-31 17:15:30 +00:00
parent 3a35883250
commit cb6c8bee47
11 changed files with 104 additions and 58 deletions

View File

@ -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
@ -550,8 +545,11 @@ class ProjectsController < ApplicationController
# 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])
@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}
@ -560,6 +558,9 @@ class ProjectsController < ApplicationController
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]

View File

@ -1,29 +1,39 @@
<h2><%= l(:label_calendar) %></h2>
<% form_tag({:action => 'calendar', :id => @project}) do %>
<% form_tag do %>
<table width="100%">
<tr>
<td align="left" style="width:150px">
<td align="left" style="width:15%">
<%= link_to_remote ('&#171; ' + (@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)}
%>
</td>
<td align="center">
<td align="center" style="width:55%">
<%= select_month(@month, :prefix => "month", :discard_type => true) %>
<%= select_year(@year, :prefix => "year", :discard_type => true) %>
<%= submit_tag l(:button_submit), :class => "button-small" %>
</td>
<td align="right" style="width:150px">
<td align="left" style="width:15%">
<a href="#" onclick="Element.toggle('trackerselect')"><%= l(:label_options) %></a>
<div id="trackerselect" class="rightbox overlay" style="width:140px; display:none;">
<p><strong><%=l(:label_tracker_plural)%></strong></p>
<% @trackers.each do |tracker| %>
<%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
<%= tracker.name %><br />
<% end %>
<p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
</div>
</td>
<td align="right" style="width:15%">
<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' &#187;'),
{: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)}
%>&nbsp;
</td>
</tr>
</table>
<% end %>
<br />
<table class="list with-cells">
<thead>

View File

@ -1,39 +1,47 @@
<div class="contextual">
<%= l(:label_export_to) %>
<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :output => 'pdf'}, :class => 'icon icon-pdf' %>
<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :output => 'pdf'}, :class => 'icon icon-pdf' %>
</div>
<h2><%= l(:label_gantt) %></h2>
<% form_tag do %>
<table width="100%">
<tr>
<td align="left">
<% form_tag do %>
<p>
<input type="text" name="months" size="2" value="<%= @months %>" />
<%= 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" %>
</p>
<% end %>
<input type="text" name="months" size="2" value="<%= @months %>" />
<%= 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" %>
</td>
<td>
<a href="#" onclick="Element.toggle('trackerselect')"><%= l(:label_options) %></a>
<div id="trackerselect" class="rightbox overlay" style="width:140px; display: none;">
<p><strong><%=l(:label_tracker_plural)%></strong></p>
<% @trackers.each do |tracker| %>
<%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
<%= tracker.name %><br />
<% end %>
<p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
</div>
</td>
<td align="right">
<%= 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 %>
</td>
</tr>
</table>
<br />
<% end %>
<% zoom = 1
@zoom.times { zoom = zoom * 2 }
@ -41,22 +49,22 @@
subject_width = 260
header_heigth = 18
headers_heigth = header_heigth
headers_height = header_heigth
show_weeks = false
show_days = false
if @zoom >1
show_weeks = true
headers_heigth = 2*header_heigth
headers_height = 2*header_heigth
if @zoom > 2
show_days = true
headers_heigth = 3*header_heigth
headers_height = 3*header_heigth
end
end
g_width = (@date_to - @date_from + 1)*zoom
g_height = [(20 * @issues.length + 6)+150, 206].max
t_height = g_height + headers_heigth
t_height = g_height + headers_height
%>
<table width="100%" style="border:0; border-collapse: collapse;">
@ -64,26 +72,26 @@ t_height = g_height + headers_heigth
<td style="width:260px;">
<div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
<div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_heigth %>px;background: #eee;" class="gantt_hdr"></div>
<div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
<div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
<%
#
# Tasks subjects
#
top = headers_heigth + 8
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>
<% top = top + 20
<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>
<% top = top + 20
end %>
</div>
</td>
<td>
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
<div style="width:<%= g_width-1 %>px;height:<%= headers_heigth %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
<div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
<%
#
# Months headers
@ -160,14 +168,14 @@ end %>
# Today red line
#
if Date.today >= @date_from and Date.today <= @date_to %>
<div style="position: absolute;height:<%= g_height %>px;top:<%= headers_heigth + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
<div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
<% end %>
<%
#
# Tasks
#
top = headers_heigth + 10
top = headers_height + 10
@issues.each do |i| %>
<%
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
@ -209,7 +217,7 @@ end %>
<table width="100%">
<tr>
<td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months %></td>
<td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months %></td>
<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>
<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>
</tr>
</table>

View File

@ -351,6 +351,7 @@ label_commits_per_author: Übertragungen pro Autor
label_view_diff: View differences
label_diff_inline: inline
label_diff_side_by_side: side by side
label_options: Options
button_login: Einloggen
button_submit: OK

View File

@ -351,6 +351,7 @@ label_commits_per_author: Commits per author
label_view_diff: View differences
label_diff_inline: inline
label_diff_side_by_side: side by side
label_options: Options
button_login: Login
button_submit: Submit

View File

@ -351,6 +351,7 @@ label_commits_per_author: Commits per author
label_view_diff: View differences
label_diff_inline: inline
label_diff_side_by_side: side by side
label_options: Options
button_login: Conexión
button_submit: Someter

View File

@ -351,6 +351,7 @@ label_commits_per_author: Commits par auteur
label_view_diff: Voir les différences
label_diff_inline: en ligne
label_diff_side_by_side: côte à côte
label_options: Options
button_login: Connexion
button_submit: Soumettre

View File

@ -351,6 +351,7 @@ label_commits_per_author: Commits per author
label_view_diff: View differences
label_diff_inline: inline
label_diff_side_by_side: side by side
label_options: Options
button_login: Login
button_submit: Invia

View File

@ -352,6 +352,7 @@ label_commits_per_author: 起票者別のコミット
label_view_diff: 差分を見る
label_diff_inline: インライン
label_diff_side_by_side: 横に並べる
label_options: Options
button_login: ログイン
button_submit: 変更

View File

@ -354,6 +354,7 @@ label_commits_per_author: Commits per author
label_view_diff: View differences
label_diff_inline: inline
label_diff_side_by_side: side by side
label_options: Options
button_login: 登录
button_submit: 提交

View File

@ -467,6 +467,12 @@ position: relative;
margin: 0 5px 5px;
}
.overlay{
position: absolute;
margin-left:0;
z-index: 50;
}
.layout-active {
background: #ECF3E1;
}