默认排序方式更改

This commit is contained in:
nieguanghui 2013-09-06 09:25:02 +08:00
parent 83acda2781
commit 7490806bf3
6 changed files with 30 additions and 27 deletions

View File

@ -54,12 +54,12 @@ class BidsController < ApplicationController
end end
else else
unless @offset == 0 unless @offset == 0
@bids = @bids.offset(@offset).limit(@limit).all.reverse @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else else
limit = @bid_count % @limit limit = @bid_count % @limit
@bids = @bids.offset(@offset).limit(limit).all.reverse @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end end
@s_state = 0 @s_state = 1
end end
#end #end
# @limit = api_offset_and_limit({:limit => 5}) # @limit = api_offset_and_limit({:limit => 5})

View File

@ -153,17 +153,17 @@ class ProjectsController < ApplicationController
@s_type = 2 @s_type = 2
end end
else else
@offset ||= @project_pages.reverse_offset @offset ||= @project_pages.reverse_offset
unless @offset == 0 unless @offset == 0
@projects = @projects.offset(@offset).limit(@limit).all.reverse @projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
else else
limit = @project_count % @limit limit = @project_count % @limit
if limit == 0 if limit == 0
limit = @limit limit = @limit
end end
@projects = @projects.offset(@offset).limit(limit).all.reverse @projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
end end
@s_type = 0 @s_type = 1
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
# @projects = @projects[@offset, @limit] # @projects = @projects[@offset, @limit]

View File

@ -213,16 +213,16 @@ class UsersController < ApplicationController
else else
@offset ||= @user_pages.reverse_offset @offset ||= @user_pages.reverse_offset
unless @offset == 0 unless @offset == 0
@users = scope.offset(@offset).limit(@limit).all.reverse @users = scope.includes(:user_status).reorder('user_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
else else
limit = @user_count % @limit limit = @user_count % @limit
if limit == 0 if limit == 0
limit = @limit limit = @limit
end end
@users = scope.offset(@offset).limit(limit).all.reverse @users = scope.includes(:user_status).reorder('user_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
end end
@s_type = 0 @s_type = 1
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
# @projects = @projects[@offset, @limit] # @projects = @projects[@offset, @limit]
end end

View File

@ -41,11 +41,12 @@ module BidsHelper
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1'))) content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1')))
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0'), :class=>"selected"), :class=>"selected")
when 1 when 1
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0')))
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1'), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0')))
end end
content = content_tag('ul', content) content = content_tag('ul', content)
content_tag('div', content, :class => "tabs") content_tag('div', content, :class => "tabs")

View File

@ -41,17 +41,19 @@ module ProjectsHelper
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'))) content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1')))
content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'))) content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2')))
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'), :class=>"selected"), :class=>"selected")
when 1 when 1
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0')))
content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'))) content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2')))
when 2
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'))) content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0')))
when 2
content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'))) content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1')))
content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0')))
end end
content = content_tag('ul', content) content = content_tag('ul', content)
content_tag('div', content, :class => "tabs") content_tag('div', content, :class => "tabs")

View File

@ -96,17 +96,17 @@ def sort_user(state)
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'))) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1')))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'))) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2')))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'), :class=>"selected"), :class=>"selected")
when 1 when 1
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0')))
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'))) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2')))
when 2
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'))) content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0')))
when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'))) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1')))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0')))
end end
content = content_tag('ul', content) content = content_tag('ul', content)
content_tag('div', content, :class => "tabs") content_tag('div', content, :class => "tabs")