增加竞赛作品的搜索功能
This commit is contained in:
parent
c1bbd8a535
commit
3119d9a9aa
|
@ -304,6 +304,36 @@ class SoftapplicationsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search
|
||||||
|
@softapplications = Softapplication.where("name like '%#{params[:name]}%'")
|
||||||
|
|
||||||
|
#new added fenyefunction
|
||||||
|
@limit = 5
|
||||||
|
@softapplication_count = @softapplications.count
|
||||||
|
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
|
||||||
|
@offset ||= @softapplication_pages.offset
|
||||||
|
|
||||||
|
#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.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_softapplication
|
def find_softapplication
|
||||||
@softapplication = Softapplication.find_by_id(params[:id])
|
@softapplication = Softapplication.find_by_id(params[:id])
|
||||||
|
|
|
@ -4,18 +4,20 @@
|
||||||
<td class="info_font" style="width: 240px; color: #15bccf"><%=l(:label_contest_innovate_community)%></td>
|
<td class="info_font" style="width: 240px; color: #15bccf"><%=l(:label_contest_innovate_community)%></td>
|
||||||
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
<td rowspan="2" width="305px">
|
<td rowspan="2" width="305px">
|
||||||
<div class="project-search" style="float: right">
|
<div class="project-search" style="float: right">
|
||||||
<%= text_field_tag 'name', params[:name], :size => 25 %>
|
<%= form_tag({:controller => 'softapplications', :action => 'search'}, :method => :get, :remote => true) do %>
|
||||||
<%= hidden_field_tag 'project_type', params[:project_type] %>
|
<%= text_field_tag 'name', params[:name], :size => 25 %>
|
||||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
<%= hidden_field_tag 'project_type', params[:project_type] %>
|
||||||
</div>
|
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><%=link_to request.host()+"/softapplications", :controller=>'softapplications', :action=>'index' %></td>
|
<td style="padding-left: 8px"><%=link_to request.host()+"/softapplications", :controller=>'softapplications', :action=>'index' %></td>
|
||||||
<td ><%=link_to l(:field_homepage), home_path %> >
|
<td ><%=link_to l(:field_homepage), home_path %> >
|
||||||
<%=link_to l(:label_contest_work), :controller=>'softapplications', :action=>'index' %>
|
<%=link_to l(:label_contest_work), :controller=>'softapplications', :action=>'index' %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
<% @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 ">
|
||||||
|
<%contest = softapplication.contests.first%>
|
||||||
|
<p><%=l(:label_attendingcontestwork_belongs_contest)%>:<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%></p>
|
||||||
|
<p><%=l(:label_attendingcontestwork_belongs_type)%>:<%= softapplication.app_type_name.truncate(10, omission: '...') %></p>
|
||||||
|
<p><%=l(:label_attendingcontestwork_adaptive_system)%>:<%= softapplication.android_min_version_available %></p>
|
||||||
|
</div>
|
||||||
|
<div style="padding-left: 53px">
|
||||||
|
<span><%=l(:label_attendingcontestwork_developers)%>:<%= softapplication.application_developers %></span>
|
||||||
|
<span style="padding-left: 50px"><%=l(:label_attendingcontestwork_release_time)%>:<%=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 class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
|
|
@ -4,36 +4,14 @@
|
||||||
|
|
||||||
<% if @softapplications.size > 0%>
|
<% if @softapplications.size > 0%>
|
||||||
<%= sort_softapplication(@s_state)%>
|
<%= sort_softapplication(@s_state)%>
|
||||||
|
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;" id="softapplications_list">
|
||||||
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
<%= render :partial => "list" %>
|
||||||
<% @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 ">
|
|
||||||
<%contest = softapplication.contests.first%>
|
|
||||||
<p><%=l(:label_attendingcontestwork_belongs_contest)%>:<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%></p>
|
|
||||||
<p><%=l(:label_attendingcontestwork_belongs_type)%>:<%= softapplication.app_type_name.truncate(10, omission: '...') %></p>
|
|
||||||
<p><%=l(:label_attendingcontestwork_adaptive_system)%>:<%= softapplication.android_min_version_available %></p>
|
|
||||||
</div>
|
|
||||||
<div style="padding-left: 53px">
|
|
||||||
<span><%=l(:label_attendingcontestwork_developers)%>:<%= softapplication.application_developers %></span>
|
|
||||||
<span style="padding-left: 50px"><%=l(:label_attendingcontestwork_release_time)%>:<%=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>
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render :partial => "layouts/no_content"%>
|
<%= render :partial => "layouts/no_content"%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<div class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
|
|
||||||
|
|
||||||
<% html_title l(:label_contest_work_list)%>
|
<% html_title l(:label_contest_work_list)%>
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
$('#softapplications_list').html('<%= escape_javascript(render(:partial => 'list' )) %>');
|
|
@ -76,6 +76,7 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
collection do
|
collection do
|
||||||
match 'new_message', via: :get
|
match 'new_message', via: :get
|
||||||
|
match 'search', via: [:get, :post]
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
match 'create_message' , via: :post
|
match 'create_message' , via: :post
|
||||||
|
|
Loading…
Reference in New Issue