应用页面列表排序(按时间排序已好,另一种排序暂未定)
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,28 +36,36 @@
|
|||
|
||||
<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
|
||||
|
||||
<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>
|
||||
<span><%= rating_for softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></span>
|
||||
<% 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>
|
||||
<span><%= rating_for softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></span>
|
||||
|
||||
</div>
|
||||
<div class="avatar-4"; style="float: left; margin-top: 7px "><%= image_tag('/images/app1.png')%></div>
|
||||
<div style="float: left; width: 600px; padding-top: 6px; margin-left: 8px"><%= softapplication.description.truncate(95, omission: '...') %></div>
|
||||
<div style="float: left; width: 200px; margin-left: 70px; margin-top: -3px; line-height: 0.5em">
|
||||
<p>所属竞赛:<%#= contest ? link_to(contest.name, show_softapplication_contest_path()) : '尚未加入竞赛'%></p>
|
||||
<p>所属类别:<%= softapplication.app_type_name %></p>
|
||||
<p>系统支持:<%= softapplication.android_min_version_available %></p>
|
||||
</div>
|
||||
<div style="padding-left: 53px">
|
||||
<span>开发人员:<%= softapplication.application_developers %></span>
|
||||
<span style="padding-left: 50px">发布时间:<%=format_time softapplication.created_at %></span>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<% else %>
|
||||
<%= render :partial => "layouts/no_content"%>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<div class="avatar-4"; style="float: left; margin-top: 7px "><%= image_tag('/images/app1.png')%></div>
|
||||
<div style="float: left; width: 600px; padding-top: 6px; margin-left: 8px"><%= softapplication.description.truncate(95, omission: '...') %></div>
|
||||
<div style="float: left; width: 200px; margin-left: 70px; margin-top: -3px; line-height: 0.5em">
|
||||
<p>所属竞赛:<%#= contest ? link_to(contest.name, show_softapplication_contest_path()) : '尚未加入竞赛'%></p>
|
||||
<p>所属类别:<%= softapplication.app_type_name %></p>
|
||||
<p>系统支持:<%= softapplication.android_min_version_available %></p>
|
||||
</div>
|
||||
<div style="padding-left: 53px">
|
||||
<span>开发人员:<%= softapplication.application_developers %></span>
|
||||
<span style="padding-left: 50px">发布时间:<%=format_time softapplication.created_at %></span>
|
||||
</div>
|
||||
<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 class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue