应用页面列表排序(按时间排序已好,另一种排序暂未定)
This commit is contained in:
parent
0eb81a24af
commit
3da6d5cd37
|
@ -13,9 +13,25 @@ class SoftapplicationsController < ApplicationController
|
||||||
@softapplication_count = @softapplications.count
|
@softapplication_count = @softapplications.count
|
||||||
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
|
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
|
||||||
@offset ||= @softapplication_pages.offset
|
@offset ||= @softapplication_pages.offset
|
||||||
@softapplications = @softapplications[@offset,@limit]
|
|
||||||
#new added end
|
|
||||||
#@softapplications = @softapplications[@offset,@limit]
|
#@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|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: @softapplications }
|
format.json { render json: @softapplications }
|
||||||
|
|
|
@ -1,2 +1,18 @@
|
||||||
module SoftapplicationsHelper
|
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
|
end
|
||||||
|
content = content_tag('ul', content)
|
||||||
|
content_tag('div', content, :class => "tabs")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
|
|
||||||
<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
|
<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
|
||||||
|
|
||||||
|
<% if @softapplications.size > 0%>
|
||||||
|
<%= sort_softapplication(@s_state)%>
|
||||||
|
|
||||||
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
||||||
<% @softapplications.each do |softapplication| %>
|
<% @softapplications.each do |softapplication| %>
|
||||||
<div>
|
<div>
|
||||||
|
@ -59,6 +62,11 @@
|
||||||
<% end %>
|
<% 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>
|
<div class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
|
||||||
|
|
||||||
<% html_title l(:label_softapplication_list)%>
|
<% html_title l(:label_softapplication_list)%>
|
Loading…
Reference in New Issue