diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3c815c7d8..5385956c1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -141,6 +141,23 @@ class AttachmentsController < ApplicationController end end + def update_file_dense + @attachment = Attachment.find(params[:attachmentid]) + if @attachment != nil + filedense = params[:newtype].to_s + if filedense == "1" + @attachment.is_public = 1 + else + @attachment.is_public = 0 + end + @attachment.save + @newfiledense = filedense + end + respond_to do |format| + format.js + end + end + def thumbnail if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if stale?(:etag => thumbnail) diff --git a/app/views/attachments/update_file_dense.js.erb b/app/views/attachments/update_file_dense.js.erb new file mode 100644 index 000000000..d99481d08 --- /dev/null +++ b/app/views/attachments/update_file_dense.js.erb @@ -0,0 +1,2 @@ +$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)), + :remote=>true,:class=>"f_l re_open",:method => :post) %>"); diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 603318cf6..089eee8ac 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -28,7 +28,10 @@
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> - 选入我的课程公开 + 选入我的课程 + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> +
diff --git a/config/routes.rb b/config/routes.rb index 3e2abce47..510872316 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -563,6 +563,7 @@ RedmineApp::Application.routes.draw do collection do match "updateType" , :via => [:get, :post] match "updateFileDense" , :via => [:get, :post] + match "update_file_dense", :via => [:post] match "renderTag" , :via => [:get, :post] match 'delete_softapplications', :via => [:get, :post] end