@@ -22,7 +22,9 module QueriesHelper | |||||
22 | end |
|
22 | end | |
23 |
|
23 | |||
24 | def column_header(column) |
|
24 | def column_header(column) | |
25 |
column.sortable ? sort_header_tag(column.sortable, :caption => column.caption |
|
25 | column.sortable ? sort_header_tag(column.sortable, :caption => column.caption, | |
|
26 | :default_order => column.default_order) : | |||
|
27 | content_tag('th', column.caption) | |||
26 | end |
|
28 | end | |
27 |
|
29 | |||
28 | def column_content(column, issue) |
|
30 | def column_content(column, issue) |
@@ -92,7 +92,7 module SortHelper | |||||
92 | # - The optional caption explicitly specifies the displayed link text. |
|
92 | # - The optional caption explicitly specifies the displayed link text. | |
93 | # - A sort icon image is positioned to the right of the sort link. |
|
93 | # - A sort icon image is positioned to the right of the sort link. | |
94 | # |
|
94 | # | |
95 |
def sort_link(column, caption |
|
95 | def sort_link(column, caption, default_order) | |
96 | key, order = session[@sort_name][:key], session[@sort_name][:order] |
|
96 | key, order = session[@sort_name][:key], session[@sort_name][:order] | |
97 | if key == column |
|
97 | if key == column | |
98 | if order.downcase == 'asc' |
|
98 | if order.downcase == 'asc' | |
@@ -104,11 +104,13 module SortHelper | |||||
104 | end |
|
104 | end | |
105 | else |
|
105 | else | |
106 | icon = nil |
|
106 | icon = nil | |
107 | order = 'desc' # changed for desc order by default |
|
107 | order = default_order | |
108 | end |
|
108 | end | |
109 | caption = titleize(Inflector::humanize(column)) unless caption |
|
109 | caption = titleize(Inflector::humanize(column)) unless caption | |
110 |
|
110 | |||
111 |
url = {:sort_key => column, :sort_order => order, : |
|
111 | url = {:sort_key => column, :sort_order => order, :status => params[:status], | |
|
112 | :issue_id => params[:issue_id], | |||
|
113 | :project_id => params[:project_id]} | |||
112 |
|
114 | |||
113 | link_to_remote(caption, |
|
115 | link_to_remote(caption, | |
114 | {:update => "content", :url => url}, |
|
116 | {:update => "content", :url => url}, | |
@@ -138,8 +140,9 module SortHelper | |||||
138 | # |
|
140 | # | |
139 | def sort_header_tag(column, options = {}) |
|
141 | def sort_header_tag(column, options = {}) | |
140 | caption = options.delete(:caption) || titleize(Inflector::humanize(column)) |
|
142 | caption = options.delete(:caption) || titleize(Inflector::humanize(column)) | |
|
143 | default_order = options.delete(:default_order) || 'asc' | |||
141 | options[:title]= l(:label_sort_by, "\"#{caption}\"") unless options[:title] |
|
144 | options[:title]= l(:label_sort_by, "\"#{caption}\"") unless options[:title] | |
142 | content_tag('th', sort_link(column, caption), options) |
|
145 | content_tag('th', sort_link(column, caption, default_order), options) | |
143 | end |
|
146 | end | |
144 |
|
147 | |||
145 | private |
|
148 | private |
@@ -16,12 +16,13 | |||||
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 QueryColumn |
|
18 | class QueryColumn | |
19 | attr_accessor :name, :sortable |
|
19 | attr_accessor :name, :sortable, :default_order | |
20 | include GLoc |
|
20 | include GLoc | |
21 |
|
21 | |||
22 | def initialize(name, options={}) |
|
22 | def initialize(name, options={}) | |
23 | self.name = name |
|
23 | self.name = name | |
24 | self.sortable = options[:sortable] |
|
24 | self.sortable = options[:sortable] | |
|
25 | self.default_order = options[:default_order] | |||
25 | end |
|
26 | end | |
26 |
|
27 | |||
27 | def caption |
|
28 | def caption | |
@@ -94,18 +95,18 class Query < ActiveRecord::Base | |||||
94 | @@available_columns = [ |
|
95 | @@available_columns = [ | |
95 | QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"), |
|
96 | QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"), | |
96 | QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"), |
|
97 | QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"), | |
97 | QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position"), |
|
98 | QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'), | |
98 | QueryColumn.new(:subject), |
|
99 | QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"), | |
99 | QueryColumn.new(:author), |
|
100 | QueryColumn.new(:author), | |
100 | QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"), |
|
101 | QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"), | |
101 | QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on"), |
|
102 | QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'), | |
102 | QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"), |
|
103 | QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"), | |
103 | QueryColumn.new(:fixed_version), |
|
104 | QueryColumn.new(:fixed_version), | |
104 | QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"), |
|
105 | QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"), | |
105 | QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"), |
|
106 | QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"), | |
106 | QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"), |
|
107 | QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"), | |
107 | QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"), |
|
108 | QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"), | |
108 | QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on"), |
|
109 | QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'), | |
109 | ] |
|
110 | ] | |
110 | cattr_reader :available_columns |
|
111 | cattr_reader :available_columns | |
111 |
|
112 |
@@ -17,9 +17,9 | |||||
17 | <thead><tr> |
|
17 | <thead><tr> | |
18 | <%= sort_header_tag('name', :caption => l(:label_project)) %> |
|
18 | <%= sort_header_tag('name', :caption => l(:label_project)) %> | |
19 | <th><%=l(:field_description)%></th> |
|
19 | <th><%=l(:field_description)%></th> | |
20 | <th><%=l(:field_is_public)%></th> |
|
|||
21 | <th><%=l(:label_subproject_plural)%></th> |
|
20 | <th><%=l(:label_subproject_plural)%></th> | |
22 |
<%= sort_header_tag('c |
|
21 | <%= sort_header_tag('is_public', :caption => l(:field_is_public), :default_order => 'desc') %> | |
|
22 | <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> | |||
23 | <th></th> |
|
23 | <th></th> | |
24 | <th></th> |
|
24 | <th></th> | |
25 | </tr></thead> |
|
25 | </tr></thead> | |
@@ -28,8 +28,8 | |||||
28 | <tr class="<%= cycle("odd", "even") %>"> |
|
28 | <tr class="<%= cycle("odd", "even") %>"> | |
29 | <td><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %> |
|
29 | <td><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %> | |
30 | <td><%= textilizable project.short_description, :project => project %> |
|
30 | <td><%= textilizable project.short_description, :project => project %> | |
31 | <td align="center"><%= image_tag 'true.png' if project.is_public? %> |
|
|||
32 | <td align="center"><%= project.children.size %> |
|
31 | <td align="center"><%= project.children.size %> | |
|
32 | <td align="center"><%= image_tag 'true.png' if project.is_public? %> | |||
33 | <td align="center"><%= format_date(project.created_on) %> |
|
33 | <td align="center"><%= format_date(project.created_on) %> | |
34 | <td align="center" style="width:10%"> |
|
34 | <td align="center" style="width:10%"> | |
35 | <small> |
|
35 | <small> |
@@ -6,7 +6,7 | |||||
6 | :method => :get}, |
|
6 | :method => :get}, | |
7 | {:title => l(:label_bulk_edit_selected_issues)}) if @project && User.current.allowed_to?(:edit_issues, @project) %> |
|
7 | {:title => l(:label_bulk_edit_selected_issues)}) if @project && User.current.allowed_to?(:edit_issues, @project) %> | |
8 | </th> |
|
8 | </th> | |
9 | <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#') %> |
|
9 | <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#', :default_order => 'desc') %> | |
10 | <% query.columns.each do |column| %> |
|
10 | <% query.columns.each do |column| %> | |
11 | <%= column_header(column) %> |
|
11 | <%= column_header(column) %> | |
12 | <% end %> |
|
12 | <% end %> |
@@ -17,10 +17,10 | |||||
17 | <%= sort_header_tag('login', :caption => l(:field_login)) %> |
|
17 | <%= sort_header_tag('login', :caption => l(:field_login)) %> | |
18 | <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> |
|
18 | <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> | |
19 | <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> |
|
19 | <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> | |
20 | <th><%=l(:field_mail)%></th> |
|
20 | <%= sort_header_tag('mail', :caption => l(:field_mail)) %> | |
21 | <%= sort_header_tag('admin', :caption => l(:field_admin)) %> |
|
21 | <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> | |
22 | <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %> |
|
22 | <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> | |
23 | <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on)) %> |
|
23 | <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> | |
24 | <th></th> |
|
24 | <th></th> | |
25 | </tr></thead> |
|
25 | </tr></thead> | |
26 | <tbody> |
|
26 | <tbody> |
General Comments 0
You need to be logged in to leave comments.
Login now