@@ -16,21 +16,21 | |||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class ProjectsController < ApplicationController |
|
18 | class ProjectsController < ApplicationController | |
19 |
|
|
19 | layout 'base' | |
20 |
|
|
20 | before_filter :find_project, :authorize, :except => [ :index, :list, :add ] | |
21 | before_filter :require_admin, :only => [ :add, :destroy ] |
|
21 | before_filter :require_admin, :only => [ :add, :destroy ] | |
22 |
|
22 | |||
23 | helper :sort |
|
23 | helper :sort | |
24 |
|
|
24 | include SortHelper | |
25 |
|
|
25 | helper :search_filter | |
26 |
|
|
26 | include SearchFilterHelper | |
27 |
|
|
27 | helper :custom_fields | |
28 |
|
|
28 | include CustomFieldsHelper | |
29 |
|
29 | |||
30 |
|
|
30 | def index | |
31 | list |
|
31 | list | |
32 |
|
|
32 | render :action => 'list' | |
33 |
|
|
33 | end | |
34 |
|
34 | |||
35 | # Lists public projects |
|
35 | # Lists public projects | |
36 | def list |
|
36 | def list | |
@@ -181,29 +181,47 class ProjectsController < ApplicationController | |||||
181 | end |
|
181 | end | |
182 | end |
|
182 | end | |
183 |
|
183 | |||
184 |
|
|
184 | # Show issues list of @project | |
185 |
|
|
185 | def list_issues | |
186 |
|
|
186 | sort_init 'issues.id', 'desc' | |
187 |
|
|
187 | sort_update | |
188 |
|
188 | |||
189 | search_filter_criteria 'issues.tracker_id', :values => "Tracker.find(:all)" |
|
189 | search_filter_init_list_issues | |
190 | search_filter_criteria 'issues.priority_id', :values => "Enumeration.find(:all, :conditions => ['opt=?','IPRI'])" |
|
190 | search_filter_update if params[:set_filter] or request.post? | |
191 | search_filter_criteria 'issues.category_id', :values => "@project.issue_categories" |
|
191 | ||
192 | search_filter_criteria 'issues.status_id', :values => "IssueStatus.find(:all)" |
|
192 | @issue_count = Issue.count(:include => :status, :conditions => search_filter_clause) | |
193 | search_filter_criteria 'issues.author_id', :values => "User.find(:all)", :label => "display_name" |
|
193 | @issue_pages = Paginator.new self, @issue_count, 15, @params['page'] | |
194 | search_filter_update if params[:set_filter] or request.post? |
|
194 | @issues = Issue.find :all, :order => sort_clause, | |
195 |
|
||||
196 | @issue_count = @project.issues.count(search_filter_clause) |
|
|||
197 | @issue_pages = Paginator.new self, @issue_count, |
|
|||
198 | 15, |
|
|||
199 | @params['page'] |
|
|||
200 | @issues = @project.issues.find :all, :order => sort_clause, |
|
|||
201 | :include => [ :author, :status, :tracker ], |
|
195 | :include => [ :author, :status, :tracker ], | |
202 | :conditions => search_filter_clause, |
|
196 | :conditions => search_filter_clause, | |
203 | :limit => @issue_pages.items_per_page, |
|
197 | :limit => @issue_pages.items_per_page, | |
204 | :offset => @issue_pages.current.offset |
|
198 | :offset => @issue_pages.current.offset | |
205 |
|
|
199 | end | |
|
200 | ||||
|
201 | # Export filtered/sorted issues list to CSV | |||
|
202 | def export_issues_csv | |||
|
203 | sort_init 'issues.id', 'desc' | |||
|
204 | sort_update | |||
|
205 | ||||
|
206 | search_filter_init_list_issues | |||
|
207 | ||||
|
208 | @issues = Issue.find :all, :order => sort_clause, | |||
|
209 | :include => [ :author, :status, :tracker ], | |||
|
210 | :conditions => search_filter_clause | |||
206 |
|
211 | |||
|
212 | export = StringIO.new | |||
|
213 | CSV::Writer.generate(export, ',') do |csv| | |||
|
214 | csv << %w(Id Status Tracker Subject Author Created Updated) | |||
|
215 | @issues.each do |issue| | |||
|
216 | csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, _('(time)', issue.created_on), _('(time)', issue.updated_on)] | |||
|
217 | end | |||
|
218 | end | |||
|
219 | export.rewind | |||
|
220 | send_data(export.read, | |||
|
221 | :type => 'text/csv; charset=utf-8; header=present', | |||
|
222 | :filename => 'export.csv') | |||
|
223 | end | |||
|
224 | ||||
207 | # Add a news to @project |
|
225 | # Add a news to @project | |
208 | def add_news |
|
226 | def add_news | |
209 | @news = @project.news.build(params[:news]) |
|
227 | @news = @project.news.build(params[:news]) | |
@@ -216,9 +234,9 class ProjectsController < ApplicationController | |||||
216 | end |
|
234 | end | |
217 |
|
235 | |||
218 | # Show news list of @project |
|
236 | # Show news list of @project | |
219 |
|
|
237 | def list_news | |
220 | @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" |
|
238 | @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" | |
221 |
|
|
239 | end | |
222 |
|
240 | |||
223 | def add_file |
|
241 | def add_file | |
224 | if request.post? |
|
242 | if request.post? | |
@@ -238,13 +256,13 class ProjectsController < ApplicationController | |||||
238 | @versions = @project.versions |
|
256 | @versions = @project.versions | |
239 | end |
|
257 | end | |
240 |
|
258 | |||
241 |
|
|
259 | # Show changelog of @project | |
242 |
|
|
260 | def changelog | |
243 | @fixed_issues = @project.issues.find(:all, |
|
261 | @fixed_issues = @project.issues.find(:all, | |
244 |
|
|
262 | :include => [ :fixed_version, :status, :tracker ], | |
245 |
|
|
263 | :conditions => [ "issue_statuses.is_closed=? and trackers.is_in_chlog=? and issues.fixed_version_id is not null", true, true] | |
246 |
|
|
264 | ) | |
247 |
|
|
265 | end | |
248 |
|
266 | |||
249 | private |
|
267 | private | |
250 | # Find project of id params[:id] |
|
268 | # Find project of id params[:id] |
@@ -17,39 +17,69 | |||||
17 |
|
17 | |||
18 | module SearchFilterHelper |
|
18 | module SearchFilterHelper | |
19 |
|
19 | |||
20 |
|
|
20 | def search_filter_criteria(name, options = {}) | |
21 |
|
|
21 | session[:search_filter] ||= {} | |
22 |
|
|
22 | session[:search_filter][name] ||= {} | |
23 | # session[:search_filter][field][:values] = options[:values] unless options[:values].nil? |
|
23 | unless session[:search_filter][name][:options] and session[:search_filter][name][:conditions] | |
24 | # session[:search_filter][field][:label] = options[:label] unless options[:label].nil? |
|
24 | session[:search_filter][name][:options] = [] | |
25 | end |
|
25 | session[:search_filter][name][:conditions] = {} | |
|
26 | yield.each { |c| | |||
|
27 | session[:search_filter][name][:options] << [c[0], c[1].to_s] | |||
|
28 | session[:search_filter][name][:conditions].store(c[1].to_s, c[2]) | |||
|
29 | } | |||
|
30 | end | |||
|
31 | end | |||
26 |
|
32 | |||
27 |
|
|
33 | def search_filter_update | |
28 |
|
|
34 | session[:search_filter].each_key {|field| session[:search_filter][field][:value] = params[field] } | |
29 | #@search_filter[:value] = params[@search_filter[:field]] |
|
35 | end | |
30 | end |
|
|||
31 |
|
36 | |||
32 |
|
|
37 | def search_filter_clause | |
33 | clause = "1=1" |
|
38 | clause = ["issues.project_id=?", @project.id] | |
34 | session[:search_filter].each {|field, criteria| clause = clause + " AND " + field + "='" + session[:search_filter][field][:value] + "'" unless session[:search_filter][field][:value].nil? || session[:search_filter][field][:value].empty? } |
|
39 | session[:search_filter].each { |k, v| | |
35 | clause |
|
40 | v[:value] ||= v[:options][0][1] | |
36 | #@search_filter[:field] + "='" + @search_filter[:value] + "'" unless @search_filter[:value].nil? || @search_filter[:value].empty? |
|
41 | if (!v[:conditions][v[:value]][0].empty?) | |
37 | end |
|
42 | clause[0] = clause[0] + " AND " + v[:conditions][v[:value]][0] | |
|
43 | clause << v[:conditions][v[:value]][1] if !v[:conditions][v[:value]][1].nil? | |||
|
44 | end | |||
|
45 | } | |||
|
46 | clause | |||
|
47 | end | |||
38 |
|
48 | |||
39 |
|
|
49 | def search_filter_tag(criteria) | |
40 | option_values = [] |
|
50 | content_tag("select", | |
41 | #values = eval @search_filter[:values_expr] |
|
51 | options_for_select(session[:search_filter][criteria][:options], session[:search_filter][criteria][:value]), | |
42 | option_values = eval session[:search_filter][field][:values] |
|
52 | :name => criteria | |
43 |
|
||||
44 | content_tag("select", |
|
|||
45 | content_tag("option", "[All]", :value => "") + |
|
|||
46 | options_from_collection_for_select(option_values, |
|
|||
47 | "id", |
|
|||
48 | session[:search_filter][field][:label] || "name", |
|
|||
49 | session[:search_filter][field][:value].to_i |
|
|||
50 | ), |
|
|||
51 | :name => field |
|
|||
52 | ) |
|
53 | ) | |
53 |
|
|
54 | end | |
|
55 | ||||
|
56 | def search_filter_init_list_issues | |||
|
57 | search_filter_criteria('status_id') { | |||
|
58 | [ ["[Open]", "O", ["issue_statuses.is_closed=?", false]], | |||
|
59 | ["[All]", "A", ["", false]] | |||
|
60 | ] + IssueStatus.find(:all).collect {|s| [s.name, s.id, ["issues.status_id=?", s.id]] } | |||
|
61 | } | |||
|
62 | ||||
|
63 | search_filter_criteria('tracker_id') { | |||
|
64 | [ ["[All]", "A", ["", false]] | |||
|
65 | ] + Tracker.find(:all).collect {|s| [s.name, s.id, ["issues.tracker_id=?", s.id]] } | |||
|
66 | } | |||
|
67 | ||||
|
68 | search_filter_criteria('priority_id') { | |||
|
69 | [ ["[All]", "A", ["", false]] | |||
|
70 | ] + Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect {|s| [s.name, s.id, ["issues.priority_id=?", s.id]] } | |||
|
71 | } | |||
|
72 | ||||
|
73 | search_filter_criteria('category_id') { | |||
|
74 | [ ["[All]", "A", ["", false]], | |||
|
75 | ["[None]", "N", ["issues.category_id is null"]] | |||
|
76 | ] + @project.issue_categories.find(:all).collect {|s| [s.name, s.id, ["issues.category_id=?", s.id]] } | |||
|
77 | } | |||
54 |
|
78 | |||
|
79 | search_filter_criteria('assigned_to_id') { | |||
|
80 | [ ["[All]", "A", ["", false]], | |||
|
81 | ["[Nobody]", "N", ["issues.assigned_to_id is null"]] | |||
|
82 | ] + User.find(:all).collect {|s| [s.display_name, s.id, ["issues.assigned_to_id=?", s.id]] } | |||
|
83 | } | |||
|
84 | end | |||
55 | end No newline at end of file |
|
85 | end |
@@ -3,11 +3,11 | |||||
3 | <form method="post" class="noborder"> |
|
3 | <form method="post" class="noborder"> | |
4 | <table cellpadding=2> |
|
4 | <table cellpadding=2> | |
5 | <tr> |
|
5 | <tr> | |
6 |
<td><%=_('Status')%>:<br /><%= search_filter_tag(" |
|
6 | <td><%=_('Status')%>:<br /><%= search_filter_tag("status_id") %></td> | |
7 |
<td><%=_('Tracker')%>:<br /><%= search_filter_tag(" |
|
7 | <td><%=_('Tracker')%>:<br /><%= search_filter_tag("tracker_id") %></td> | |
8 |
<td><%=_('Priority')%>:<br /><%= search_filter_tag(" |
|
8 | <td><%=_('Priority')%>:<br /><%= search_filter_tag("priority_id") %></td> | |
9 |
<td><%=_('Category')%>:<br /><%= search_filter_tag(" |
|
9 | <td><%=_('Category')%>:<br /><%= search_filter_tag("category_id") %></td> | |
10 |
<td><%=_('A |
|
10 | <td><%=_('Assigned to')%>:<br /><%= search_filter_tag("assigned_to_id") %></td> | |
11 | <td valign="bottom"> |
|
11 | <td valign="bottom"> | |
12 | <%= submit_tag _('Apply filter') %> |
|
12 | <%= submit_tag _('Apply filter') %> | |
13 | <%= end_form_tag %> |
|
13 | <%= end_form_tag %> | |
@@ -17,12 +17,14 | |||||
17 | <%= end_form_tag %> |
|
17 | <%= end_form_tag %> | |
18 | </td> |
|
18 | </td> | |
19 | </tr> |
|
19 | </tr> | |
20 |
|
|
20 | </table> | |
21 |
|
21 | | ||
22 | |
|
|||
23 |
|
||||
24 | <table border="0" cellspacing="1" cellpadding="2" class="listTableContent"> |
|
22 | <table border="0" cellspacing="1" cellpadding="2" class="listTableContent"> | |
25 |
|
23 | |||
|
24 | <tr><td colspan="7" align="right"> | |||
|
25 | <small><%= link_to 'Export to CSV', :action => 'export_issues_csv', :id => @project.id %></small> | |||
|
26 | </td></tr> | |||
|
27 | ||||
26 | <tr class="ListHead"> |
|
28 | <tr class="ListHead"> | |
27 | <%= sort_header_tag('issues.id', :caption => '#') %> |
|
29 | <%= sort_header_tag('issues.id', :caption => '#') %> | |
28 | <%= sort_header_tag('issue_statuses.name', :caption => _('Status')) %> |
|
30 | <%= sort_header_tag('issue_statuses.name', :caption => _('Status')) %> | |
@@ -48,8 +50,8 | |||||
48 | <p> |
|
50 | <p> | |
49 | <%= pagination_links_full @issue_pages %> |
|
51 | <%= pagination_links_full @issue_pages %> | |
50 | [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ] |
|
52 | [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ] | |
51 |
|
|
53 | </p> | |
52 |
|
54 | |||
53 |
|
55 | |||
54 | <p> |
|
56 | <p> | |
55 | <%= link_to_if_authorized '» ' + _('Report an issue'), :controller => 'projects', :action => 'add_issue', :id => @project %> |
|
57 | <%= link_to_if_authorized '» ' + _('Report an issue'), :controller => 'projects', :action => 'add_issue', :id => @project %> |
@@ -15,20 +15,25 | |||||
15 | <tr style="background-color:#CEE1ED"> |
|
15 | <tr style="background-color:#CEE1ED"> | |
16 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, |
|
16 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, | |
17 | :set_filter => 1, |
|
17 | :set_filter => 1, | |
18 |
" |
|
18 | "#{field_name}" => row.id %></td> | |
19 | <% for status in @statuses %> |
|
19 | <% for status in @statuses %> | |
20 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }), |
|
20 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }), | |
21 | :controller => 'projects', :action => 'list_issues', :id => @project, |
|
21 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
22 | :set_filter => 1, |
|
22 | :set_filter => 1, | |
23 |
" |
|
23 | "status_id" => status.id, | |
24 |
" |
|
24 | "#{field_name}" => row.id %></td> | |
25 | <% end %> |
|
25 | <% end %> | |
26 |
<td align="center"><%= aggregate data, { field_name => row.id, "closed" => 0 } |
|
26 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }), | |
|
27 | :controller => 'projects', :action => 'list_issues', :id => @project, | |||
|
28 | :set_filter => 1, | |||
|
29 | "#{field_name}" => row.id, | |||
|
30 | "status_id" => "O" %></td> | |||
27 | <td align="center"><%= aggregate data, { field_name => row.id, "closed" => 1 } %></td> |
|
31 | <td align="center"><%= aggregate data, { field_name => row.id, "closed" => 1 } %></td> | |
28 | <td align="center"><%= link_to (aggregate data, { field_name => row.id }), |
|
32 | <td align="center"><%= link_to (aggregate data, { field_name => row.id }), | |
29 | :controller => 'projects', :action => 'list_issues', :id => @project, |
|
33 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
30 | :set_filter => 1, |
|
34 | :set_filter => 1, | |
31 |
" |
|
35 | "#{field_name}" => row.id, | |
|
36 | "status_id" => "A" %></td> | |||
32 | <% end %> |
|
37 | <% end %> | |
33 | </tr> |
|
38 | </tr> | |
34 | </table> No newline at end of file |
|
39 | </table> |
@@ -5,6 +5,14 Copyright (C) 2006 Jean-Philippe Lang | |||||
5 | http://redmine.sourceforge.net/ |
|
5 | http://redmine.sourceforge.net/ | |
6 |
|
6 | |||
7 |
|
7 | |||
|
8 | == xx/xx/2006 | |||
|
9 | ||||
|
10 | * More filter options in issues list | |||
|
11 | * Issues list exportable to CSV | |||
|
12 | * Fixed: Error on tables creation with PostgreSQL (rev5) | |||
|
13 | * Fixed: SQL error in "issue reports" view with PostgreSQL (rev5) | |||
|
14 | ||||
|
15 | ||||
8 | == 06/25/2006 - v0.1.0 |
|
16 | == 06/25/2006 - v0.1.0 | |
9 |
|
17 | |||
10 | * multiple users/multiple projects |
|
18 | * multiple users/multiple projects |
General Comments 0
You need to be logged in to leave comments.
Login now