调整竞赛列表页面中的排序问题
This commit is contained in:
parent
3a9c7a036f
commit
b542f8072d
|
@ -33,15 +33,6 @@ class ContestsController < ApplicationController
|
|||
if params[:contest_sort_type].present?
|
||||
case params[:contest_sort_type]
|
||||
when '0'
|
||||
unless @offset == 0
|
||||
@contests = @contests.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @contest_count % @limit
|
||||
limit = @limit if limit == 0
|
||||
@contests = @contests.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_state = 0
|
||||
when '1'
|
||||
unless @offset == 0
|
||||
@contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
|
@ -49,6 +40,15 @@ class ContestsController < ApplicationController
|
|||
limit = @limit if limit == 0
|
||||
@contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_state = 0
|
||||
when '1'
|
||||
unless @offset == 0
|
||||
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @contest_count % @limit
|
||||
limit = @limit if limit == 0
|
||||
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_state = 1
|
||||
when '2'
|
||||
unless @offset == 0
|
||||
|
@ -62,11 +62,11 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
else
|
||||
unless @offset == 0
|
||||
@contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse
|
||||
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @contest_count % @limit
|
||||
limit = @limit if limit == 0
|
||||
@contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse
|
||||
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_state = 1
|
||||
end
|
||||
|
|
|
@ -62,12 +62,12 @@ module ContestsHelper
|
|||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
|
|
Loading…
Reference in New Issue