资源库 只能删除上传者为自己的资源
This commit is contained in:
parent
3c6484269d
commit
cf243d47e5
|
@ -14,6 +14,7 @@
|
|||
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
|
||||
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
|
||||
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname %></li>
|
||||
<li style="display: none"><%= attach.author_id %></li>
|
||||
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
|
||||
<li style="display: none"><%= attach.id %></li>
|
||||
</ul>
|
||||
|
|
|
@ -113,10 +113,10 @@
|
|||
<%= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>
|
||||
</div>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" id="contextMenu">
|
||||
<li><a tabindex="-1" href="#" onclick="preview();" onfocus="this.blur()">预览</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="rename();" onfocus="this.blur()">重命名</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="show_send();" onfocus="this.blur()" >发送</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="delete_file();" onfocus="this.blur()">删除</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)preview();" onfocus="this.blur()">预览</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)rename();" onfocus="this.blur()">重命名</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)show_send();" onfocus="this.blur()" >发送</a></li>
|
||||
<li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)delete_file();" onfocus="this.blur()">删除</a></li>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
|
@ -322,6 +322,8 @@ $(".resourcesList").click(function(e) {
|
|||
document.oncontextmenu = function() {return true;}
|
||||
line.children().css("background-color",'white');
|
||||
id = line.children().last().html();
|
||||
user_id = line.children().eq(5).html();
|
||||
if(user_id === '<%= User.current.id%>') {
|
||||
res_name = line.children().eq(1).children().attr('title');
|
||||
res_link = line.children().eq(1).html();
|
||||
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
|
||||
|
@ -332,6 +334,9 @@ $(".resourcesList").click(function(e) {
|
|||
'<% end %>');
|
||||
$("#res_name").focus();
|
||||
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
|
||||
}else{
|
||||
alert('您无法修改此资源!')
|
||||
}
|
||||
}
|
||||
String.prototype.trim = function() {
|
||||
var str = this,
|
||||
|
@ -391,12 +396,17 @@ $(".resourcesList").click(function(e) {
|
|||
}
|
||||
line.children().css("background-color", 'white');
|
||||
id = line.children().last().html();
|
||||
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')){
|
||||
user_id = line.children().eq(5).html();
|
||||
if(user_id === '<%= User.current.id%>') {
|
||||
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id+'&type='+$('#type').val()
|
||||
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val()
|
||||
});
|
||||
}
|
||||
}else{
|
||||
alert('您无法删除此资源!')
|
||||
}
|
||||
}
|
||||
|
||||
//id 发送的id
|
||||
|
|
Loading…
Reference in New Issue