diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 3d4d33be8..b4b92cc38 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -162,16 +162,21 @@ class FilesController < ApplicationController end # 返回制定资源类型的资源列表 + # added by nwb def getattachtype sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" - - @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort - + + if @project + @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 + @attachtype = params[:type].to_i @contenttype = params[:contentType].to_s diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb new file mode 100644 index 000000000..fe3311bdd --- /dev/null +++ b/app/views/files/_course_sort_by_attachtypel.html.erb @@ -0,0 +1,71 @@ +<% selAttachType =@attachtype %> +<% selContentType =@contenttype %> +<% attachmenttypes = @course.attachmenttypes %> +<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> +<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %> + + + + + + + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %> + <%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %> + <%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %> + <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> + + + + + <% @containers.each do |container| %> + <% next if container.attachments.empty? -%> + <% container.attachments.each do |file| %> + <% if isTypeOk(file,selAttachType,selContentType) %> + "> + + + + + + + + + + + + + <% end -%> + <% end -%> + <% reset_cycle %> + <% end -%> + + + + +
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= number_to_human_size(file.filesize) %> + <%= file.attachmentstype.typeName %> +   + + <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, + :attachment => file,:contentype=>selContentType} %> + + <%= file.show_suffix_type %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
+
+ <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
+
+ +
+ diff --git a/app/views/files/create.html.erb b/app/views/files/create.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index c8a250fe8..0eca9c1ed 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -9,9 +9,7 @@ $('#name-issue').val(""); $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); -//$("#put-tag-form- -<%=@obj.class%>- -<%=@obj.id%>").hide(); +$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide(); $("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); <% else %> diff --git a/app/views/files/getattachtype.js.erb b/app/views/files/getattachtype.js.erb index 3bc9863b2..88722073f 100644 --- a/app/views/files/getattachtype.js.erb +++ b/app/views/files/getattachtype.js.erb @@ -1,5 +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%> <%else%> -$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>'); +<% 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 b5990109f..68c5f5cac 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -90,6 +90,19 @@ <%end%> } + function attachmenttypes_searchex(value) { + <% if @project%> + $.ajax({ + url: '<%=getattachtype_project_files_path(project_id: @project)%>', + type: "POST", + data: { + type: encodeURIComponent(value), + contentType: $('#attach_sufix_browse').val() + } + + }).complete(eval_ajax); + <%end%> + } function course_attachmenttypes_searchex(value) { <% if @course%>