diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 5cbf1ab2f..5acc14055 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -99,6 +99,7 @@ class FilesController < ApplicationController
@sort = ""
@order = ""
@is_remote = true
+ @q = params[:name].strip
if params[:sort]
order_by = params[:sort].split(":")
@sort = order_by[0]
@@ -107,24 +108,26 @@ class FilesController < ApplicationController
end
sort = "#{@sort} #{@order}"
end
+ # show_attachments [@course]
begin
q = "%#{params[:name].strip}%"
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
if params[:insite]
if q == "%%"
- @result = []
- @searched_attach = paginateHelper @result,10
+ @project_attachment_result = []
+ @searched_attach = paginateHelper @project_attachment_result, 10
else
- @result = find_public_attache q,sort
- @result = visable_attachemnts_insite @result,@project
- @searched_attach = paginateHelper @result,10
+ @project_attachment_result = find_public_attache q,sort
+ @project_attachment_result = visable_attachemnts_insite @project_attachment_result, @project
+ @searched_attach = paginateHelper @project_attachment_result, 10
end
else
- @result = find_project_attache q,@project,sort
- @result = visable_attachemnts @result
- @searched_attach = paginateHelper @result,10
- end
+ @project_attachment_result = find_project_attache q, @project,sort
+ @project_attachment_result = visable_attachemnts @project_attachment_result
+ @searched_attach = paginateHelper @project_attachment_result,10
+ @tag_list = get_course_tag_list @project
+ end
#rescue Exception => e
# #render 'stores'
# redirect_to search_course_files_url
@@ -200,23 +203,10 @@ class FilesController < ApplicationController
if sort == ""
sort = "created_on DESC"
end
- ids = ""
- len = 0
- 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)
+ if keywords != "%%"
+ resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
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}%").
- reorder(sort)
+ resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' "). reorder(sort)
end
end
diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb
index 1b4e96a8d..f86729da6 100644
--- a/app/views/files/_project_list.html.erb
+++ b/app/views/files/_project_list.html.erb
@@ -8,15 +8,15 @@
- <%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename),
- :title => file.filename+"\n"+file.description.to_s,
- :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %>
+ <%= link_to truncate(file.filename,length: 35, omission: '...'),
+ download_named_attachment_path(file.id, file.filename),
+ :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') %>
- <% if file.is_public? == false%>
- 私有
- <%end %>
-
+ <% if file.is_public? == false%>
+ 私有
+ <%end %>
+
上传时间:<%= format_date(file.created_on)%>
@@ -33,11 +33,13 @@
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
+
-
- <%= render :partial => 'file_tools', :locals => {:project => @project, :file => file, :tag_name => @tag_name, :delete_allowed => delete_allowed} %>
+
+
@@ -51,9 +53,10 @@
<% if project_attachments.count == 10%>
<% 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%>
- <%=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" %>
+
+ <%=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%>
diff --git a/app/views/files/search_project.js.erb b/app/views/files/search_project.js.erb
index f64b8beeb..69752e0d9 100644
--- a/app/views/files/search_project.js.erb
+++ b/app/views/files/search_project.js.erb
@@ -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)})%>");
\ No newline at end of file
+<% 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 %>
\ No newline at end of file