diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d341f0f6e..900487364 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 000000000..79d0da0bb --- /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 57ac897d2..98e31f874 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 a43b2ae07..c71a1483e 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 a5dc322cf..c743c2151 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 000000000..8335716fd Binary files /dev/null and b/public/images/Edit/edit.png differ