@@ -186,24 +186,42 class ProjectsController < ApplicationController | |||
|
186 | 186 |
|
|
187 | 187 |
|
|
188 | 188 | |
|
189 | search_filter_criteria 'issues.tracker_id', :values => "Tracker.find(:all)" | |
|
190 | search_filter_criteria 'issues.priority_id', :values => "Enumeration.find(:all, :conditions => ['opt=?','IPRI'])" | |
|
191 | search_filter_criteria 'issues.category_id', :values => "@project.issue_categories" | |
|
192 | search_filter_criteria 'issues.status_id', :values => "IssueStatus.find(:all)" | |
|
193 | search_filter_criteria 'issues.author_id', :values => "User.find(:all)", :label => "display_name" | |
|
189 | search_filter_init_list_issues | |
|
194 | 190 |
|
|
195 | 191 | |
|
196 |
|
|
|
197 |
|
|
|
198 | 15, | |
|
199 | @params['page'] | |
|
200 | @issues = @project.issues.find :all, :order => sort_clause, | |
|
192 | @issue_count = Issue.count(:include => :status, :conditions => search_filter_clause) | |
|
193 | @issue_pages = Paginator.new self, @issue_count, 15, @params['page'] | |
|
194 | @issues = Issue.find :all, :order => sort_clause, | |
|
201 | 195 | :include => [ :author, :status, :tracker ], |
|
202 | 196 | :conditions => search_filter_clause, |
|
203 | 197 | :limit => @issue_pages.items_per_page, |
|
204 | 198 | :offset => @issue_pages.current.offset |
|
205 | 199 |
|
|
206 | 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 | |
|
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 | 225 | # Add a news to @project |
|
208 | 226 | def add_news |
|
209 | 227 | @news = @project.news.build(params[:news]) |
@@ -17,39 +17,69 | |||
|
17 | 17 | |
|
18 | 18 | module SearchFilterHelper |
|
19 | 19 | |
|
20 |
|
|
|
20 | def search_filter_criteria(name, options = {}) | |
|
21 | 21 |
|
|
22 |
|
|
|
23 | # session[:search_filter][field][:values] = options[:values] unless options[:values].nil? | |
|
24 | # session[:search_filter][field][:label] = options[:label] unless options[:label].nil? | |
|
22 | session[:search_filter][name] ||= {} | |
|
23 | unless session[:search_filter][name][:options] and session[:search_filter][name][:conditions] | |
|
24 | session[:search_filter][name][:options] = [] | |
|
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 | |
|
25 | 31 |
|
|
26 | 32 | |
|
27 | 33 |
|
|
28 | 34 |
|
|
29 | #@search_filter[:value] = params[@search_filter[:field]] | |
|
30 | 35 |
|
|
31 | 36 | |
|
32 | 37 |
|
|
33 | clause = "1=1" | |
|
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? } | |
|
38 | clause = ["issues.project_id=?", @project.id] | |
|
39 | session[:search_filter].each { |k, v| | |
|
40 | v[:value] ||= v[:options][0][1] | |
|
41 | if (!v[:conditions][v[:value]][0].empty?) | |
|
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 | } | |
|
35 | 46 |
|
|
36 | #@search_filter[:field] + "='" + @search_filter[:value] + "'" unless @search_filter[:value].nil? || @search_filter[:value].empty? | |
|
37 | 47 |
|
|
38 | 48 | |
|
39 |
|
|
|
40 | option_values = [] | |
|
41 | #values = eval @search_filter[:values_expr] | |
|
42 | option_values = eval session[:search_filter][field][:values] | |
|
43 | ||
|
49 | def search_filter_tag(criteria) | |
|
44 | 50 |
|
|
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 | |
|
51 | options_for_select(session[:search_filter][criteria][:options], session[:search_filter][criteria][:value]), | |
|
52 | :name => criteria | |
|
52 | 53 | ) |
|
53 | 54 |
|
|
54 | 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 | } | |
|
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 | 85 | end No newline at end of file |
@@ -3,11 +3,11 | |||
|
3 | 3 | <form method="post" class="noborder"> |
|
4 | 4 | <table cellpadding=2> |
|
5 | 5 | <tr> |
|
6 |
<td><%=_('Status')%>:<br /><%= search_filter_tag(" |
|
|
7 |
<td><%=_('Tracker')%>:<br /><%= search_filter_tag(" |
|
|
8 |
<td><%=_('Priority')%>:<br /><%= search_filter_tag(" |
|
|
9 |
<td><%=_('Category')%>:<br /><%= search_filter_tag(" |
|
|
10 |
<td><%=_('A |
|
|
6 | <td><%=_('Status')%>:<br /><%= search_filter_tag("status_id") %></td> | |
|
7 | <td><%=_('Tracker')%>:<br /><%= search_filter_tag("tracker_id") %></td> | |
|
8 | <td><%=_('Priority')%>:<br /><%= search_filter_tag("priority_id") %></td> | |
|
9 | <td><%=_('Category')%>:<br /><%= search_filter_tag("category_id") %></td> | |
|
10 | <td><%=_('Assigned to')%>:<br /><%= search_filter_tag("assigned_to_id") %></td> | |
|
11 | 11 | <td valign="bottom"> |
|
12 | 12 | <%= submit_tag _('Apply filter') %> |
|
13 | 13 | <%= end_form_tag %> |
@@ -18,11 +18,13 | |||
|
18 | 18 | </td> |
|
19 | 19 | </tr> |
|
20 | 20 |
|
|
21 | ||
|
22 | 21 |
|
|
23 | ||
|
24 | 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 | 28 | <tr class="ListHead"> |
|
27 | 29 | <%= sort_header_tag('issues.id', :caption => '#') %> |
|
28 | 30 | <%= sort_header_tag('issue_statuses.name', :caption => _('Status')) %> |
@@ -15,20 +15,25 | |||
|
15 | 15 | <tr style="background-color:#CEE1ED"> |
|
16 | 16 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, |
|
17 | 17 | :set_filter => 1, |
|
18 |
" |
|
|
18 | "#{field_name}" => row.id %></td> | |
|
19 | 19 | <% for status in @statuses %> |
|
20 | 20 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }), |
|
21 | 21 | :controller => 'projects', :action => 'list_issues', :id => @project, |
|
22 | 22 | :set_filter => 1, |
|
23 |
" |
|
|
24 |
" |
|
|
23 | "status_id" => status.id, | |
|
24 | "#{field_name}" => row.id %></td> | |
|
25 | 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 | 31 | <td align="center"><%= aggregate data, { field_name => row.id, "closed" => 1 } %></td> |
|
28 | 32 | <td align="center"><%= link_to (aggregate data, { field_name => row.id }), |
|
29 | 33 | :controller => 'projects', :action => 'list_issues', :id => @project, |
|
30 | 34 | :set_filter => 1, |
|
31 |
" |
|
|
35 | "#{field_name}" => row.id, | |
|
36 | "status_id" => "A" %></td> | |
|
32 | 37 | <% end %> |
|
33 | 38 | </tr> |
|
34 | 39 | </table> No newline at end of file |
@@ -5,6 +5,14 Copyright (C) 2006 Jean-Philippe Lang | |||
|
5 | 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 | 16 | == 06/25/2006 - v0.1.0 |
|
9 | 17 | |
|
10 | 18 | * multiple users/multiple projects |
General Comments 0
You need to be logged in to leave comments.
Login now