项目资源搜索
This commit is contained in:
parent
0a1aa9e569
commit
c4718f992c
|
@ -99,6 +99,7 @@ class FilesController < ApplicationController
|
||||||
@sort = ""
|
@sort = ""
|
||||||
@order = ""
|
@order = ""
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
|
@q = params[:name].strip
|
||||||
if params[:sort]
|
if params[:sort]
|
||||||
order_by = params[:sort].split(":")
|
order_by = params[:sort].split(":")
|
||||||
@sort = order_by[0]
|
@sort = order_by[0]
|
||||||
|
@ -107,24 +108,26 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
sort = "#{@sort} #{@order}"
|
sort = "#{@sort} #{@order}"
|
||||||
end
|
end
|
||||||
|
# show_attachments [@course]
|
||||||
begin
|
begin
|
||||||
q = "%#{params[:name].strip}%"
|
q = "%#{params[:name].strip}%"
|
||||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||||
if params[:insite]
|
if params[:insite]
|
||||||
if q == "%%"
|
if q == "%%"
|
||||||
@result = []
|
@project_attachment_result = []
|
||||||
@searched_attach = paginateHelper @result,10
|
@searched_attach = paginateHelper @project_attachment_result, 10
|
||||||
else
|
else
|
||||||
@result = find_public_attache q,sort
|
@project_attachment_result = find_public_attache q,sort
|
||||||
@result = visable_attachemnts_insite @result,@project
|
@project_attachment_result = visable_attachemnts_insite @project_attachment_result, @project
|
||||||
@searched_attach = paginateHelper @result,10
|
@searched_attach = paginateHelper @project_attachment_result, 10
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@result = find_project_attache q,@project,sort
|
@project_attachment_result = find_project_attache q, @project,sort
|
||||||
@result = visable_attachemnts @result
|
@project_attachment_result = visable_attachemnts @project_attachment_result
|
||||||
@searched_attach = paginateHelper @result,10
|
@searched_attach = paginateHelper @project_attachment_result,10
|
||||||
end
|
|
||||||
|
|
||||||
|
@tag_list = get_course_tag_list @project
|
||||||
|
end
|
||||||
#rescue Exception => e
|
#rescue Exception => e
|
||||||
# #render 'stores'
|
# #render 'stores'
|
||||||
# redirect_to search_course_files_url
|
# redirect_to search_course_files_url
|
||||||
|
@ -200,23 +203,10 @@ class FilesController < ApplicationController
|
||||||
if sort == ""
|
if sort == ""
|
||||||
sort = "created_on DESC"
|
sort = "created_on DESC"
|
||||||
end
|
end
|
||||||
ids = ""
|
if keywords != "%%"
|
||||||
len = 0
|
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
|
||||||
count = project.versions.count
|
|
||||||
project.versions.each do |version|
|
|
||||||
len = len + 1
|
|
||||||
if len != count
|
|
||||||
ids += version.id.to_s + ','
|
|
||||||
else
|
|
||||||
ids += version.id.to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if ids.blank?
|
|
||||||
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ", like: "%#{keywords}%").
|
|
||||||
reorder(sort)
|
|
||||||
else
|
else
|
||||||
resultSet = Attachment.where("((attachments.container_type = 'Project' And attachments.container_id = '#{project.id}') OR (container_type = 'Version' AND container_id IN (#{ids}))) AND filename LIKE :like ", like: "%#{keywords}%").
|
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' "). reorder(sort)
|
||||||
reorder(sort)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,15 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostDes">
|
<div class="homepagePostDes">
|
||||||
<div class="homepagePostTitle break_word mt-4">
|
<div class="homepagePostTitle break_word mt-4">
|
||||||
<%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename),
|
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||||
:title => file.filename+"\n"+file.description.to_s,
|
download_named_attachment_path(file.id, file.filename),
|
||||||
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %>
|
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %>
|
||||||
<%= file_preview_eye(file, class: 'preview') %>
|
<%= file_preview_eye(file, class: 'preview') %>
|
||||||
<span id="image_private_<%= file.id%>">
|
<span id="image_private_<%= file.id%>">
|
||||||
<% if file.is_public? == false%>
|
<% if file.is_public? == false%>
|
||||||
<span class="img_private ml5">私有</span>
|
<span class="img_private ml5">私有</span>
|
||||||
<%end %>
|
<%end %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt5">
|
<div class="mt5">
|
||||||
<span class="fontGrey2 mr15 fl">上传时间:<%= format_date(file.created_on)%></span>
|
<span class="fontGrey2 mr15 fl">上传时间:<%= format_date(file.created_on)%></span>
|
||||||
|
@ -33,11 +33,13 @@
|
||||||
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostSetting">
|
<div class="homepagePostSetting">
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li class="homepagePostSettingIcon">
|
<li class="homepagePostSettingIcon">
|
||||||
<%= render :partial => 'file_tools', :locals => {:project => @project, :file => file, :tag_name => @tag_name, :delete_allowed => delete_allowed} %>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,9 +53,10 @@
|
||||||
|
|
||||||
<% if project_attachments.count == 10%>
|
<% if project_attachments.count == 10%>
|
||||||
<% if params[:action] == 'search' %>
|
<% if params[:action] == 'search' %>
|
||||||
<%=link_to "点击展开更多", search_project_files_path({:project_id => project.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
<%=link_to "点击展开更多", search_project_files_path({:project_id => project.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
||||||
<%else%>
|
<%else%>
|
||||||
<%=link_to "点击展开更多", project_files_path({:project_id => project.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
|
||||||
|
<%=link_to "点击展开更多", project_files_path({:project_id => project.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
||||||
<%end%>
|
<%end%>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
$("#course_list").html("<%= escape_javascript(render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @result,sort:@sort,order:@order,project_attachments:@searched_attach,:manage_allowed => User.current.allowed_to?(:manage_files, @project)})%>");
|
<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> //搜索的时候有时候是需要加载下一页,有时候是直接替换当前 #course_list。这个根据 page来判定
|
||||||
|
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list',
|
||||||
|
:locals => {project: @project, all_attachments:@result, sort:@sort, order:@order, project_attachments:@searched_attach})%>");
|
||||||
|
<% else %>
|
||||||
|
$("#course_list").html("<%= escape_javascript(render :partial => 'files/project_list',:locals => {project:@project, all_attachments:@result, sort:@sort, order:@order,project_attachments:@searched_attach})%>");
|
||||||
|
$("#attachment_count").html("<%= @project_attachment_result.count %>")
|
||||||
|
<% end %>
|
Loading…
Reference in New Issue