资源库 删除
This commit is contained in:
parent
107a5686d1
commit
f97a55e164
|
@ -823,9 +823,16 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 删除用户资源
|
||||
# 删除用户资源,分为批量删除 和 单个删除
|
||||
def user_resource_delete
|
||||
if params[:resource_id].present?
|
||||
Attachment.delete(params[:resource_id])
|
||||
elsif params[:checkbox1].present?
|
||||
params[:checkbox1].each do |id|
|
||||
Attachment.delete(id)
|
||||
end
|
||||
end
|
||||
|
||||
#@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
|
||||
if(params[:type].nil? || params[:type] == "1") #全部
|
||||
if User.current.id.to_i == params[:id].to_i
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% attachments.each do |attach| %>
|
||||
<ul class="resourcesList">
|
||||
<li class="resourcesListCheckbox fl">
|
||||
<input name="checkbox1" type="checkbox" onclick="checkAllBox($(this));" class="resourcesCheckbox" />
|
||||
<input name="checkbox1[]" type="checkbox" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
|
||||
</li>
|
||||
<li class="resourcesListName fl">
|
||||
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->
|
||||
|
|
|
@ -82,22 +82,26 @@
|
|||
<li class="resourcesListTime fl">上传时间</li>
|
||||
</ul>
|
||||
</div>
|
||||
<form id="resources_list_form">
|
||||
<div id="resources_list" class="resourcesList">
|
||||
|
||||
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
|
||||
|
||||
</div>
|
||||
<div class="resourcesListOption">
|
||||
<div class="resourcesCheckAll">
|
||||
<input id="checkboxAll" type="checkbox" value="" class="resourcesCheckbox" />
|
||||
<input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="replyGrey mr15">全选</a>
|
||||
<a href="javascript:void(0);" class="replyGrey">删除</a>
|
||||
<a href="javascript:void(0);" class="replyGrey mr15" onclick="all_select();">全选</a>
|
||||
<a href="javascript:void(0);" class="replyGrey" onclick="batch_delete();">删除</a>
|
||||
<div class="resourcesSelectSend">
|
||||
<div class="fl">选择 <span class="c_red" id="res_count">0</span> 个资源</div>
|
||||
<div class="resourcesSelectSendButton">
|
||||
<a href="javascript:void(0);" class="c_blue db">发送</a>
|
||||
<a href="javascript:void(0);" class="c_blue db" onclick="batch_send();">发送</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id="upload_box" style="display: none">
|
||||
<%= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>
|
||||
|
@ -182,7 +186,7 @@ $(".resourcesList").click(function(e) {
|
|||
//只要有一个选中了就是true
|
||||
function checkboxSelected(){
|
||||
selected = false;
|
||||
$("#resources_list").find("input[name='checkbox1']").each(function(){
|
||||
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
|
||||
if($(this).attr('checked') == true){
|
||||
selected = true;
|
||||
}
|
||||
|
@ -192,7 +196,7 @@ $(".resourcesList").click(function(e) {
|
|||
//只有全选才是true
|
||||
function checkboxAllSelected(){
|
||||
allSelected = true;
|
||||
$("#resources_list").find("input[name='checkbox1']").each(function(){
|
||||
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
|
||||
if($(this).attr('checked') == undefined){
|
||||
allSelected = false;
|
||||
}
|
||||
|
@ -202,7 +206,7 @@ $(".resourcesList").click(function(e) {
|
|||
//只有全部不选才是true
|
||||
function checkboxAllDeselected(){
|
||||
allDeselected = true;
|
||||
$("#resources_list").find("input[name='checkbox1']").each(function(){
|
||||
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
|
||||
if($(this).attr('checked') == 'checked'){
|
||||
allDeselected = false;
|
||||
}
|
||||
|
@ -223,27 +227,42 @@ $(".resourcesList").click(function(e) {
|
|||
//获取当前checkbox选中的数目
|
||||
function getCheckBoxSeletedCount(){
|
||||
var i = 0;
|
||||
$("#resources_list").find("input[name='checkbox1']").each(function(){
|
||||
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
|
||||
if($(this).attr('checked') == 'checked'){
|
||||
i ++;
|
||||
}
|
||||
});
|
||||
return i;
|
||||
}
|
||||
$("#checkboxAll").click(function(e){
|
||||
//全选反选
|
||||
function all_select(){
|
||||
|
||||
if($(this).attr('checked')){
|
||||
$("#resources_list").find("input[name='checkbox1']").each(function(){
|
||||
if($("#checkboxAll").attr('checked')){
|
||||
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
|
||||
$(this).attr('checked',true);
|
||||
});
|
||||
$("#res_count").html('<%= @attachments.size%>');
|
||||
$("#res_count").html(getCheckBoxSeletedCount());
|
||||
}else{
|
||||
$("#resources_list").find("input[name='checkbox1']").each(function(){
|
||||
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
|
||||
$(this).attr('checked',false);
|
||||
});
|
||||
$("#res_count").html(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
//批量删除
|
||||
function batch_delete(){
|
||||
var data = $("#resources_list_form").serialize();
|
||||
if(data != "" && confirm('确认要删除这些资源吗?')) {
|
||||
$.post(
|
||||
'<%= user_resource_delete_user_path(@user)%>',
|
||||
$("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交
|
||||
function (data) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function show_send(){
|
||||
$("#contextMenu").hide();
|
||||
|
|
Loading…
Reference in New Issue