diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ee524ec55..9171407eb 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -16,7 +16,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class FilesController < ApplicationController - layout 'base_projects'#by young + if @project + layout 'base_projects' #by young + else + layout 'base_courses' + end menu_item :files before_filter :find_project_by_project_id#, :except => [:getattachtype] @@ -122,6 +126,7 @@ class FilesController < ApplicationController end end end + @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] show_attachments @containers @@ -261,20 +266,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 + + + #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 + end + + show_attachments @containers @attachtype = params[:type].to_i @contenttype = params[:contentType].to_s 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 d00a51bc1..a1dae9a33 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -2,11 +2,11 @@ <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> - - <%= l(:label_coursefile_sharingarea) %> - +<%= t(:label_user_course) %>资源共享区
+ + <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @course) %>
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %> @@ -55,7 +55,7 @@ <% if sufixtypes.any? %>   - <%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') + options_for_select(sufixtypes), + <%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes), :onchange => "course_attachment_contenttypes_searchex(this.value)" %> <% end %>
@@ -67,6 +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_course_file)) -%> \ No newline at end of file + +<% 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 532cf0e6c..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(:project_module_files)) -%> \ No newline at end of file +<% 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 new file mode 100644 index 000000000..7f67189ac --- /dev/null +++ b/app/views/files/getattachtype.html.erb @@ -0,0 +1,249 @@ + +<% if @isproject %> + <%= render :partial => 'project_file', locals: {project: @project} %> +<% else %> + <%= render :partial => 'course_file', locals: {course: @course} %> +<% end %> + + + + + + diff --git a/app/views/files/getattachtype.js.erb b/app/views/files/getattachtype.js.erb index 7acf849ce..88722073f 100644 --- a/app/views/files/getattachtype.js.erb +++ b/app/views/files/getattachtype.js.erb @@ -1,13 +1,13 @@ <% if @attachtype==0 && @contenttype=='0' %> - <% if @project%> - $("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); - <% elsif @course%> - $("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); - <%end%> +<% if @project%> +$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); +<% elsif @course%> +$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); +<%end%> <%else%> - <% if @project%> - $("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>') - <% elsif @course%> - $("#all_browse_div").html('<%= j(render partial: "course_sort_by_attachtypel")%>') - <%end%>; +<% if @project%> +$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>') +<% elsif @course%> +$("#all_browse_div").html('<%= j(render partial: "course_sort_by_attachtypel")%>') +<%end%>; <%end%> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index fcf54de75..69b41fc28 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,248 +1,249 @@ - -<% if @isproject %> - <%= render :partial => 'project_file', locals: {project: @project} %> -<% else %> - <%= render :partial => 'course_file', locals: {course: @course} %> -<% end %> - - - - - - + +<% if @isproject %> + <%= render :partial => 'project_file', locals: {project: @project} %> +<% else %> + <%= render :partial => 'course_file', locals: {course: @course} %> +<% end %> + + + + + + diff --git a/app/views/versions/_form.html.erb b/app/views/versions/_form.html.erb index df3b2ec4b..72c95ad7f 100644 --- a/app/views/versions/_form.html.erb +++ b/app/views/versions/_form.html.erb @@ -15,7 +15,7 @@

- <%= f.text_field :wiki_page_title, :label => :label_wiki_page, :maxlength => 60, :disabled => @project.wiki.nil? %> + <%= f.text_field :wiki_page_title, :label => :label_wiki_page, :disabled => @project.wiki.nil? %>

diff --git a/app/views/wiki/diff.html.erb b/app/views/wiki/diff.html.erb index c4769cdfa..adeaa7cab 100644 --- a/app/views/wiki/diff.html.erb +++ b/app/views/wiki/diff.html.erb @@ -28,6 +28,6 @@

-
+
<%= simple_format_without_paragraph @diff.to_html %>
diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb index 1fdbcf92f..88c280608 100644 --- a/app/views/wiki/edit.html.erb +++ b/app/views/wiki/edit.html.erb @@ -46,7 +46,7 @@ - <%= render :partial => 'attachments/form' %> + <%= render :partial => 'attachments/form',:locals => {:container => @page} %>