应用页面列表排序(按时间排序已好,另一种排序暂未定)
This commit is contained in:
parent
0eb81a24af
commit
3da6d5cd37
|
@ -13,9 +13,25 @@ class SoftapplicationsController < ApplicationController
|
|||
@softapplication_count = @softapplications.count
|
||||
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
|
||||
@offset ||= @softapplication_pages.offset
|
||||
@softapplications = @softapplications[@offset,@limit]
|
||||
#new added end
|
||||
#@softapplications = @softapplications[@offset,@limit]
|
||||
#new added end
|
||||
|
||||
#new added sort
|
||||
if params[:softapplication_sort_type].present?
|
||||
case params[:softapplication_sort_type]
|
||||
when '0'
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@s_state = 0
|
||||
when '1'
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
#new added end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @softapplications }
|
||||
|
|
|
@ -1,2 +1,18 @@
|
|||
module SoftapplicationsHelper
|
||||
def sort_softapplication(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '1'}))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '0'}, :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '1'}, :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '0'}))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,10 @@
|
|||
|
||||
<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
|
||||
|
||||
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
||||
<% if @softapplications.size > 0%>
|
||||
<%= sort_softapplication(@s_state)%>
|
||||
|
||||
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
||||
<% @softapplications.each do |softapplication| %>
|
||||
<div>
|
||||
<span style="font-size: 15px; margin-right: 10px;"><strong><%= link_to softapplication.name, softapplication, :target => "_blank" %></strong></span>
|
||||
|
@ -57,7 +60,12 @@
|
|||
<div style="border-left: 1px solid #d9d8d8; border-bottom: 1px solid #d9d8d8; margin-left: 50px; padding-bottom: 10px; margin-bottom: 20px; width: 66%"></div>
|
||||
<div class="underline-contests_one" style="margin-top: -7px"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
<%= render :partial => "layouts/no_content"%>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue