From 25dba88a083d37e74695460894a9d856701d871b Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 13 May 2014 16:34:53 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2=202.?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8B=E8=BD=BD=E7=95=8C=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8C=89=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=B5=8F=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 1 + app/helpers/files_helper.rb | 19 ++++++++++++++++--- app/views/files/_new.html.erb | 2 +- app/views/files/_sort_by_attachtypel.html.erb | 3 ++- app/views/files/getattachtype.js.erb | 2 +- app/views/files/index.html.erb | 18 +++++++++++------- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + 8 files changed, 34 insertions(+), 13 deletions(-) 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? %>

- <%= 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? %> - - <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), +       + + <%= 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? %> - - <%= select_tag "attach_sufix_browse", content_tag('option', '') +options_for_select(sufixtypes), +   + + <%= 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 @@