summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-05 17:28:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-05 17:28:02 +0000
commit54ff294da164d9c8a0659610019f801ae4788068 (patch)
tree1a844a450847536b2303058332ef23a321f66ad3 /app
parent80a60247f527825aa5e02e19bcaec4bd864fce2a (diff)
downloadredmine-54ff294da164d9c8a0659610019f801ae4788068.tar.gz
redmine-54ff294da164d9c8a0659610019f801ae4788068.zip
More appropriate default sort order on sortable columns.
Sortable column added on issue subject (#580). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1121 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/queries_helper.rb4
-rw-r--r--app/helpers/sort_helper.rb11
-rw-r--r--app/models/query.rb11
-rw-r--r--app/views/admin/projects.rhtml6
-rw-r--r--app/views/issues/_list.rhtml2
-rw-r--r--app/views/users/list.rhtml8
6 files changed, 24 insertions, 18 deletions
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 3011d3aec..a58c5d0ea 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -22,7 +22,9 @@ module QueriesHelper
end
def column_header(column)
- column.sortable ? sort_header_tag(column.sortable, :caption => column.caption) : content_tag('th', column.caption)
+ column.sortable ? sort_header_tag(column.sortable, :caption => column.caption,
+ :default_order => column.default_order) :
+ content_tag('th', column.caption)
end
def column_content(column, issue)
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index dfd681fff..155e7e5e3 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -92,7 +92,7 @@ module SortHelper
# - The optional caption explicitly specifies the displayed link text.
# - A sort icon image is positioned to the right of the sort link.
#
- def sort_link(column, caption=nil)
+ def sort_link(column, caption, default_order)
key, order = session[@sort_name][:key], session[@sort_name][:order]
if key == column
if order.downcase == 'asc'
@@ -104,11 +104,13 @@ module SortHelper
end
else
icon = nil
- order = 'desc' # changed for desc order by default
+ order = default_order
end
caption = titleize(Inflector::humanize(column)) unless caption
- url = {:sort_key => column, :sort_order => order, :issue_id => params[:issue_id], :project_id => params[:project_id]}
+ url = {:sort_key => column, :sort_order => order, :status => params[:status],
+ :issue_id => params[:issue_id],
+ :project_id => params[:project_id]}
link_to_remote(caption,
{:update => "content", :url => url},
@@ -138,8 +140,9 @@ module SortHelper
#
def sort_header_tag(column, options = {})
caption = options.delete(:caption) || titleize(Inflector::humanize(column))
+ default_order = options.delete(:default_order) || 'asc'
options[:title]= l(:label_sort_by, "\"#{caption}\"") unless options[:title]
- content_tag('th', sort_link(column, caption), options)
+ content_tag('th', sort_link(column, caption, default_order), options)
end
private
diff --git a/app/models/query.rb b/app/models/query.rb
index 7127a464f..a4103c08a 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -16,12 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class QueryColumn
- attr_accessor :name, :sortable
+ attr_accessor :name, :sortable, :default_order
include GLoc
def initialize(name, options={})
self.name = name
self.sortable = options[:sortable]
+ self.default_order = options[:default_order]
end
def caption
@@ -94,18 +95,18 @@ class Query < ActiveRecord::Base
@@available_columns = [
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"),
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"),
- QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position"),
- QueryColumn.new(:subject),
+ QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'),
+ QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
QueryColumn.new(:author),
QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"),
- QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on"),
+ QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"),
QueryColumn.new(:fixed_version),
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"),
- QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on"),
+ QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
]
cattr_reader :available_columns
diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml
index d35c484b5..c42845622 100644
--- a/app/views/admin/projects.rhtml
+++ b/app/views/admin/projects.rhtml
@@ -17,9 +17,9 @@
<thead><tr>
<%= sort_header_tag('name', :caption => l(:label_project)) %>
<th><%=l(:field_description)%></th>
- <th><%=l(:field_is_public)%></th>
<th><%=l(:label_subproject_plural)%></th>
- <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
+ <%= sort_header_tag('is_public', :caption => l(:field_is_public), :default_order => 'desc') %>
+ <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
<th></th>
<th></th>
</tr></thead>
@@ -28,8 +28,8 @@
<tr class="<%= cycle("odd", "even") %>">
<td><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %>
<td><%= textilizable project.short_description, :project => project %>
- <td align="center"><%= image_tag 'true.png' if project.is_public? %>
<td align="center"><%= project.children.size %>
+ <td align="center"><%= image_tag 'true.png' if project.is_public? %>
<td align="center"><%= format_date(project.created_on) %>
<td align="center" style="width:10%">
<small>
diff --git a/app/views/issues/_list.rhtml b/app/views/issues/_list.rhtml
index d8e3102df..ff91f34f7 100644
--- a/app/views/issues/_list.rhtml
+++ b/app/views/issues/_list.rhtml
@@ -6,7 +6,7 @@
:method => :get},
{:title => l(:label_bulk_edit_selected_issues)}) if @project && User.current.allowed_to?(:edit_issues, @project) %>
</th>
- <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#') %>
+ <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#', :default_order => 'desc') %>
<% query.columns.each do |column| %>
<%= column_header(column) %>
<% end %>
diff --git a/app/views/users/list.rhtml b/app/views/users/list.rhtml
index 7415af308..e12aa3425 100644
--- a/app/views/users/list.rhtml
+++ b/app/views/users/list.rhtml
@@ -17,10 +17,10 @@
<%= sort_header_tag('login', :caption => l(:field_login)) %>
<%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
<%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
- <th><%=l(:field_mail)%></th>
- <%= sort_header_tag('admin', :caption => l(:field_admin)) %>
- <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
- <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on)) %>
+ <%= sort_header_tag('mail', :caption => l(:field_mail)) %>
+ <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %>
+ <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
+ <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %>
<th></th>
</tr></thead>
<tbody>