From 8badbb1e7861851b1de13db209dc9eb9190d1df0 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 14 May 2014 15:03:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E9=99=84=E4=BB=B6=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=B1=BB=E5=9E=8B=E7=BC=96=E8=BE=91=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E4=B8=8E=E9=80=BB=E8=BE=91=202.=E6=B7=BB=E5=8A=A0=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E8=B5=84=E6=BA=90=E7=B1=BB=E5=9E=8B=E7=BC=96=E8=BE=91?= =?UTF-8?q?js=E3=80=81control=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 11 ++++++ app/views/attachments/_type_edit.html.erb | 14 +++++++ app/views/files/_show_all_attachment.html.erb | 1 + app/views/files/_sort_by_attachtypel.html.erb | 14 ++++++- app/views/files/index.html.erb | 37 ++++++++++++++++++ config/routes.rb | 7 +++- public/images/Edit/edit.png | Bin 0 -> 522 bytes 7 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 app/views/attachments/_type_edit.html.erb create mode 100644 public/images/Edit/edit.png diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d341f0f6..90048736 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -62,6 +62,17 @@ class AttachmentsController < ApplicationController end end + #更新资源文件类型 + def updateType + @attachment = Attachment.find(params[:attachmentid]) + if @attachment != nil + @attachment.attachtype = params[:newtype] + @attachment.save + render :text =>'success' + else + render :text=>'error' + end + end def thumbnail if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) diff --git a/app/views/attachments/_type_edit.html.erb b/app/views/attachments/_type_edit.html.erb new file mode 100644 index 00000000..79d0da0b --- /dev/null +++ b/app/views/attachments/_type_edit.html.erb @@ -0,0 +1,14 @@ +<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %> +<% if attachmenttypes.any? %> + + <%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box"+attachment.id.to_s , + :onclick =>"$('#put-tag-form-" +attachment.id.to_s+ "').show(); + $('#attach_type_id_label" +attachment.id.to_s+ "').hide(); + $('#edit_box" +attachment.id.to_s+ "').hide();") if edit_allowed %> + +<% end %> + diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 57ac897d..98e31f87 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -1,3 +1,4 @@ +<% attachmenttypes = @project.attachmenttypes %> <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> <% edit_allowed = User.current.allowed_to?(:manage_files, @project) %> - \ No newline at end of file + + diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index a43b2ae0..c71a1483 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -317,4 +317,41 @@ ; }); } + + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index a5dc322c..c743c215 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -456,7 +456,12 @@ RedmineApp::Application.routes.draw do get 'attachments/autocomplete' match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post] post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' - resources :attachments, :only => [:show, :destroy] + post 'attachments/updateType/:attachmentid/:newtype' ,:to => 'attachments#updateType', :attachmentid => /\d+/, :newtype => /.*/ + resources :attachments, :only => [:show, :destroy] do + collection do + match "updateType" , via: [:get, :post] + end + end resources :groups do member do diff --git a/public/images/Edit/edit.png b/public/images/Edit/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..8335716fd5f9994eca802b8b14fb43c667bcc034 GIT binary patch literal 522 zcmV+l0`>igP)Pft(g&!0d4|DQhl|Nrg@{~ubrZp3Q+~ymoxxm8*H4N^pv1Yip)*8iT zxaN1O|Nnnp_5bP)+t({+c&Ek2#xlS#b^{t;j635SH*4VjT z*<#CZXO|5F$dCp79t`2(;b06m;ObIawo8j`bN;_O^Zx&%B%tP+|GVZnojSDGvFh|1 zI|h&eGrK(D8Zitwy}-`$|HbSB|394j|NrT#ubU=2AKo#?$-T4Mhhb8qH-<(G1NP2z zY6WXP6?Ab`x9hCl3ZDR=0#P6q#-$m>03hf8sxH@A9c8}B$+01(K)x;zYXPwd5c2~u zFA#G9F$WN{0Wk{@GZRe8Kt+l`EDOYvKr8~p0zk|SGl-(B3^afV01ba!p4w(>hyVZp M07*qoM6N<$f^G@~i~s-t literal 0 HcmV?d00001