默认排序方式更改

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
else
unless @offset == 0
@bids = @bids.offset(@offset).limit(@limit).all.reverse
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
@bids = @bids.offset(@offset).limit(limit).all.reverse
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end
@s_state = 0
@s_state = 1
end
#end
# @limit = api_offset_and_limit({:limit => 5})

View File

@ -155,15 +155,15 @@ class ProjectsController < ApplicationController
else
@offset ||= @project_pages.reverse_offset
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
limit = @project_count % @limit
if limit == 0
limit = @limit
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
@s_type = 0
@s_type = 1
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
# @projects = @projects[@offset, @limit]

View File

@ -214,15 +214,15 @@ class UsersController < ApplicationController
else
@offset ||= @user_pages.reverse_offset
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
limit = @user_count % @limit
if limit == 0
limit = @limit
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
@s_type = 0
@s_type = 1
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
# @projects = @projects[@offset, @limit]
end

View File

@ -41,11 +41,12 @@ module BidsHelper
content = ''.html_safe
case state
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_time), calls_path(:bid_sort_type => '0'), :class=>"selected"), :class=>"selected")
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_time), calls_path(:bid_sort_type => '0')))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")

View File

@ -41,17 +41,19 @@ module ProjectsHelper
content = ''.html_safe
case state
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_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
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_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')))
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_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
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")

View File

@ -96,17 +96,17 @@ def sort_user(state)
content = ''.html_safe
case state
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_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
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_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')))
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_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
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")