diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 075a54f65..a2dd8c869 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -74,6 +74,7 @@ class FilesController < ApplicationController
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
@attachtype = params[:type].to_i
+ @contenttype = params[:contentType].to_s
respond_to do |format|
format.js
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index ffa1348fd..16a3d8b58 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -44,9 +44,22 @@ module FilesHelper
File.new(zipfile_name,'w+')
end
- def browseByCategory
- isCategoryBrowser = 1
- #isCategoryBrowser
+ # 判断指定的资源时候符合类型
+ def isTypeOk(attachment, type, contentType)
+ result = false
+ if type != 0
+ if attachment.attachtype == type
+ result = true
+ end
+ else
+ result = true
+ end
+ if result
+ if contentType != l(:attachment_all) && contentType != attachment.suffix_type
+ result = false
+ end
+ end
+ result
end
diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb
index fcb916e3b..4c1b97fa1 100644
--- a/app/views/files/_new.html.erb
+++ b/app/views/files/_new.html.erb
@@ -13,7 +13,7 @@
<% if attachmenttypes.any? %>
<%=l(:attachment_type)%>
- <%= select_tag "attachment_type", content_tag('option', '') +
+ <%= select_tag "attachment_type",
options_from_collection_for_select(attachmenttypes, "id",
"typeName") %>
diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb
index 82d2a7b87..5d5f28653 100644
--- a/app/views/files/_sort_by_attachtypel.html.erb
+++ b/app/views/files/_sort_by_attachtypel.html.erb
@@ -1,4 +1,5 @@
<% selAttachType =@attachtype %>
+<% selContentType =@contenttype %>
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
@@ -27,7 +28,7 @@
<% @containers.each do |container| %>
<% next if container.attachments.empty? -%>
<% container.attachments.each do |file| %>
- <% if file.attachtype==selAttachType %>
+ <% if isTypeOk(file,selAttachType,selContentType) %>
">
<%= 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;" %>
<%= format_time(file.created_on) %>
diff --git a/app/views/files/getattachtype.js.erb b/app/views/files/getattachtype.js.erb
index 4f13cc883..fe8458e20 100644
--- a/app/views/files/getattachtype.js.erb
+++ b/app/views/files/getattachtype.js.erb
@@ -1,4 +1,4 @@
- <% if @attachtype==0%>
+ <% if @attachtype==0 && @contenttype==l(:attachment_all)%>
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
<%else%>
$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>');
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index 5abacf294..7c8129c59 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -184,13 +184,15 @@
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
<% if attachmenttypes.any? %>
- <%=l(:attachment_browse)%>
- <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
+
+ <%=l(:attachment_browse)%>
+ <%= select_tag "attachment_browse", content_tag('option',l(:attachment_all)) +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
:onchange=>"attachmenttypes_searchex(this.value)"%>
<% end %>
<% if sufixtypes.any? %>
- <%=l(:attachment_sufix_browse)%>
- <%= select_tag "attach_sufix_browse", content_tag('option', '') +options_for_select(sufixtypes),
+
+ <%=l(:attachment_sufix_browse)%>
+ <%= select_tag "attach_sufix_browse", content_tag('option', l(:attachment_all)) +options_for_select(sufixtypes),
:onchange=>"attachment_contenttypes_searchex(this.value)"%>
<% end %>
@@ -286,7 +288,8 @@