diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index f34a757e2..3d1970656 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -84,7 +84,7 @@ class FilesController < ApplicationController @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] @containers += @project.versions.includes(:attachments).reorder(sort).all - getattachtype + show_attachments @containers render :layout => !request.xhr? @@ -122,7 +122,7 @@ class FilesController < ApplicationController end end end - getattachtype + @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] show_attachments @containers @@ -262,21 +262,63 @@ class FilesController < ApplicationController 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" + sort='' + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + end + + if order_by.count == 1 + sort += "#{Attachment.table_name}.#{attribute} asc " + elsif order_by.count == 2 + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + end + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end if @project + @isproject = true @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort - elsif @course - @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] - end - show_attachments @containers + @containers += @project.versions.includes(:attachments).reorder(sort).all - @attachtype = params[:type].to_i - @contenttype = params[:contentType].to_s - - respond_to do |format| - format.js - format.html + show_attachments @containers + @attachtype = params[:type].to_i + @contenttype = params[:contentType].to_s + render :layout => 'base_projects' + elsif @course + @isproject = false + @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] + show_attachments @containers + @attachtype = params[:type].to_i + @contenttype = params[:contentType].to_s + render :layout => 'base_courses' end + + + + # respond_to do |format| + # format.js + # format.html + # end + end end diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 55a36e125..a1dae9a33 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -67,7 +67,16 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
- <%= render :partial => 'course_show_all_attachment' %> + <%#= render :partial => 'course_show_all_attachment' %> + <% if (@attachtype==0 && @contenttype=='0') || (@attachtype.nil? && @contenttype.nil?) %> + + <%= render partial: "course_show_all_attachment"%> + + <%else%> + + <%= render partial: "course_sort_by_attachtypel"%> + + <%end%>
<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 84a86d209..315314828 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -69,7 +69,17 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
- <%= render :partial => 'show_all_attachment' %> + <%#= render :partial => 'show_all_attachment' %> + <% if (@attachtype==0 && @contenttype=='0') || (@attachtype.nil? && @contenttype.nil?) %> + + <%= render partial: "show_all_attachment"%> + + + <%else%> + + <%= render partial: "sort_by_attachtypel"%> + + <%end%>
<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/getattachtype.html.erb b/app/views/files/getattachtype.html.erb index 6ffba58be..7f67189ac 100644 --- a/app/views/files/getattachtype.html.erb +++ b/app/views/files/getattachtype.html.erb @@ -1,13 +1,249 @@ -<% if @attachtype==0 && @contenttype=='0' %> - <% if @project%> - <%= render partial: "show_all_attachment"%> - <% elsif @course%> - <%= render partial: "course_show_all_attachment"%> - <%end%> -<%else%> - <% if @project%> - <%= render partial: "sort_by_attachtypel"%> - <% elsif @course%> - <%= render partial: "course_sort_by_attachtypel"%> - <%end%>; -<%end%> + +<% if @isproject %> + <%= render :partial => 'project_file', locals: {project: @project} %> +<% else %> + <%= render :partial => 'course_file', locals: {course: @course} %> +<% end %> + + + + + +