diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index a46e6e555..cd3870e9a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -77,28 +77,25 @@ class FilesController < ApplicationController if params[:insite] if q == "%%" @result = [] - @searched_attach = paginateHelper @result,10 + # @searched_attach = paginateHelper @result,10 else @result = find_public_attache q,sort @result = visable_attachemnts_insite @result,@course - @searched_attach = paginateHelper @result,10 + # @searched_attach = paginateHelper @result,10 end else @result = find_course_attache q,@course,sort @result = visable_attachemnts @result - - @all_attachments = @result - @limit = 10 - @feedback_count = @all_attachments.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - @offset ||= @feedback_pages.offset - #@curse_attachments_all = @all_attachments[@offset, @limit] - @obj_attachments = paginateHelper @all_attachments,10 - - # @searched_attach = paginateHelper @result,10 - + # @searched_attach = paginateHelper @result,10 @tag_list = get_course_tag_list @course end + @all_attachments = @result + @limit = 10 + @feedback_count = @all_attachments.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @obj_attachments = paginateHelper @all_attachments,10 #rescue Exception => e # #render 'stores' # redirect_to search_course_files_url @@ -153,18 +150,26 @@ class FilesController < ApplicationController if params[:insite] if q == "%%" @project_attachment_result = [] - @searched_attach = paginateHelper @project_attachment_result, 10 + # @searched_attach = paginateHelper @project_attachment_result, 10 else @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 + # @searched_attach = paginateHelper @project_attachment_result, 10 end else @project_attachment_result = find_project_attache q, @project,sort @project_attachment_result = visable_attachemnts @project_attachment_result - @searched_attach = paginateHelper @project_attachment_result,10 + # @searched_attach = paginateHelper @project_attachment_result,10 @tag_list = get_project_tag_list @project end + + @all_attachments = @project_attachment_result + @limit = 10 + @feedback_count = @all_attachments.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @obj_attachments = paginateHelper @all_attachments,10 #rescue Exception => e # #render 'stores' # redirect_to search_course_files_url diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index 36dc80a18..faf254015 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -66,17 +66,10 @@ <% end %> <% end %> -<% if project_attachments.count == 10%> - <% if params[:action] == 'search_project' %> - - - - <%=link_to "点击展开更多", search_project_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 => @page),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %> - <%end%> -<% end%> + + diff --git a/app/views/files/index.js.erb b/app/views/files/index.js.erb index 134598bf7..982d19329 100644 --- a/app/views/files/index.js.erb +++ b/app/views/files/index.js.erb @@ -1,8 +1,9 @@ <% if @course %> - $("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>"); + $("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments}) %>"); $("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); <% elsif @project %> - $("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list', :locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments})%>"); + $("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>"); + $("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); <% elsif @org_subfield %> $("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/org_subfield_list', :locals => {org_subfield:@org_subfield, all_attachments:@all_attachments, sort:@sort, order:@order, org_subfield_attachments:@obj_attachments})%>"); <%end %> \ No newline at end of file diff --git a/app/views/files/search_project.js.erb b/app/views/files/search_project.js.erb index 69752e0d9..f88438d57 100644 --- a/app/views/files/search_project.js.erb +++ b/app/views/files/search_project.js.erb @@ -1,7 +1,2 @@ -<% 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 +$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>"); +$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); diff --git a/app/views/files/search_tag_attachment.js.erb b/app/views/files/search_tag_attachment.js.erb index 8d2b29fe9..dff75023b 100644 --- a/app/views/files/search_tag_attachment.js.erb +++ b/app/views/files/search_tag_attachment.js.erb @@ -2,6 +2,6 @@ $("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>"); $("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); <% else %> - $("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>"); - $("#attachment_count").html("<%= @result_search_project.count%>") + $("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>"); + $("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); <% end %>