From eeda25add119adc937d1ef929bdadb2f3940a55e Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 19 Nov 2014 11:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=B5=84=E6=BA=90=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E4=B8=8E=E7=A7=81=E6=9C=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 17 +++++++++++++++++ app/views/attachments/update_file_dense.js.erb | 2 ++ app/views/files/_course_file.html.erb | 5 ++++- config/routes.rb | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/views/attachments/update_file_dense.js.erb 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