设置资源公开与私有功能

This commit is contained in:
z9hang 2014-11-19 11:03:23 +08:00
parent 0821320dfe
commit eeda25add1
4 changed files with 24 additions and 1 deletions

View File

@ -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)

View File

@ -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) %>");

View File

@ -28,7 +28,10 @@
<div class="re_con_box">
<div class=" ">
<%= 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" %>
<a href="#" class="f_l re_select">选入我的课程</a><a href="javascript:void(0)" class="f_l re_open">公开</a>
<a href="#" class="f_l re_select">选入我的课程</a>
<span id="is_public_<%= file.id %>">
<%= 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 %>
</span>
</div>
<div class="cl"></div>
<div class="">

View File

@ -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