搜索算法
This commit is contained in:
parent
aed57c6c0a
commit
3b7e8483e3
|
@ -88,7 +88,7 @@ module AttachmentsHelper
|
|||
def render_attachments_for_new_project(project, limit=nil)
|
||||
# 查询条件
|
||||
params[:q] ||= ""
|
||||
filename_condition = params[:q]
|
||||
filename_condition = params[:q].strip
|
||||
|
||||
attachAll = Attachment.scoped
|
||||
# 当前项目所有资源
|
||||
|
@ -96,13 +96,13 @@ module AttachmentsHelper
|
|||
# attachments = Attachment.where("container_type = '#{project.class}' and container_id = #{project.id}")
|
||||
|
||||
# 除去当前项目的所有资源
|
||||
nobelong_attach = Attachment.where("container_type <> '#{project.class}' and container_id <> #{project.id}") unless project.blank?
|
||||
nobelong_attach = Attachment.where("!(container_type = '#{project.class}' and container_id = #{project.id})") unless project.blank?
|
||||
|
||||
# 搜索域确定
|
||||
domain = project.nil? ? attachAll : nobelong_attach
|
||||
|
||||
# 搜索到的资源
|
||||
searched_attach = domain.where("filename like '%#{filename_condition}%' ").limit(limit).order('created_on desc')
|
||||
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
searched_attach = private_filter searched_attach
|
||||
searched_attach = paginateHelper(searched_attach, 10)
|
||||
|
||||
|
|
|
@ -115,9 +115,9 @@ div.pagination{
|
|||
<span class="borad-title"><%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>文件共享专区</span>
|
||||
|
||||
<div class="content-title-top">
|
||||
<%= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
<div class="clearfix"></div>
|
||||
<div id="file_buttons" class="hidden">
|
||||
<div id="file_buttons" class="nhidden">
|
||||
<%= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
<%= link_to('关联已有文件', 'javascript:void(0);', :onclick => "$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
|
||||
|
|
Loading…
Reference in New Issue