资源模块,默认按时间降序排列

This commit is contained in:
z9hang 2015-03-31 09:34:27 +08:00
parent 5bbc562abd
commit e2eaae63f4
4 changed files with 12 additions and 12 deletions

View File

@ -134,6 +134,8 @@ class FilesController < ApplicationController
attribute = "created_on" attribute = "created_on"
when "quotes" when "quotes"
attribute = "quotes" attribute = "quotes"
else
attribute = "created_on"
end end
@sort = order_by[0] @sort = order_by[0]
@order = order_by[1] @order = order_by[1]
@ -148,15 +150,9 @@ class FilesController < ApplicationController
sort += "," sort += ","
end end
end end
# if order_by.count == 1
# sort += "#{Attachment.table_name}.#{attribute} asc " if attribute
# elsif order_by.count == 2
# sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1]
# end
# if sort_type != params[:sort].split(",").last
# sort += ","
# end
end end
else
sort = "#{Attachment.table_name}.created_on desc"
end end
@containers = [ Project.includes(:attachments).find(@project.id)] @containers = [ Project.includes(:attachments).find(@project.id)]
@ -198,6 +194,8 @@ class FilesController < ApplicationController
attribute = "created_on" attribute = "created_on"
when "quotes" when "quotes"
attribute = "quotes" attribute = "quotes"
else
attribute = "created_on"
end end
@sort = order_by[0] @sort = order_by[0]
@order = order_by[1] @order = order_by[1]
@ -213,6 +211,8 @@ class FilesController < ApplicationController
end end
end end
end end
else
sort = "#{Attachment.table_name}.created_on desc"
end end
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]

View File

@ -20,7 +20,7 @@
<div class=""> <div class="">
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %> <% if User.current.logged? %>
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %>
<%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %>

View File

@ -24,8 +24,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% if @curse_attachments != nil %> <% if @obj_attachments != nil %>
<% @curse_attachments.each do |file| %> <% @obj_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of?(@project)%> <%if file.is_public == 0 && !User.current.member_of?(@project)%>
<%next%> <%next%>
<%end%> <%end%>

View File

@ -1,6 +1,6 @@
<div id="resource_list"> <div id="resource_list">
<% if @isproject %> <% if @isproject %>
<%= render :partial => 'project_file_new', locals: {project: @project} %> <%= render :partial => 'project_file', locals: {project: @project} %>
<% else %> <% else %>
<%= render :partial => 'course_file', locals: {course: @course} %> <%= render :partial => 'course_file', locals: {course: @course} %>
<% end %> <% end %>