From 4876e6669aae37e9e1f75ee3df1addaeb28af6e5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 18 Mar 2016 11:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=99=84=E4=BB=B6=E5=B1=80?= =?UTF-8?q?=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 3 +-- app/views/files/_course_file.html.erb | 12 ++---------- app/views/files/_course_file_filter_order.html.erb | 9 +++++++++ app/views/files/search_tag_attachment.js.erb | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 app/views/files/_course_file_filter_order.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b6ac99f11..7ae1b85f8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -207,8 +207,7 @@ class FilesController < ApplicationController sort = "created_on DESC" end if keywords != "%%" - resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%"). - reorder(sort) + resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort) else resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort) end diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index b548092cf..50b1d0639 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -108,16 +108,8 @@

共有 <%= @all_attachments.count%> 个资源

-

- <% if @order == "asc" %> - 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /  - <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /  - <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序 - <% else %> - 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /  - <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>  /  - <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序 - <% end %> +

+ <%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>

diff --git a/app/views/files/_course_file_filter_order.html.erb b/app/views/files/_course_file_filter_order.html.erb new file mode 100644 index 000000000..b5890fec6 --- /dev/null +++ b/app/views/files/_course_file_filter_order.html.erb @@ -0,0 +1,9 @@ +<% if @order == "asc" %> + 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => true %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /  + <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /  + <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序 +<% else %> + 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey" , :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /  + <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>  /  + <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序 +<% end %> \ No newline at end of file diff --git a/app/views/files/search_tag_attachment.js.erb b/app/views/files/search_tag_attachment.js.erb index 31df68b6a..3003d8b98 100644 --- a/app/views/files/search_tag_attachment.js.erb +++ b/app/views/files/search_tag_attachment.js.erb @@ -1,5 +1,6 @@ <% if @course %> $("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>"); + $("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>"); $("#attachment_count").html("<%= @result.count%>") <% 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}) %>");