From f97a55e16438e0408b2b5939fcc03b7bb42e97d2 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 20 Aug 2015 14:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 9 ++++- app/views/users/_resources_list.html.erb | 2 +- app/views/users/user_resource.html.erb | 47 +++++++++++++++++------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 76ce9efaf..f62286973 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 7a18a037b..62e819b43 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -3,7 +3,7 @@ <% attachments.each do |attach| %> +
+ <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> +
- +
- 全选 - 删除 + 全选 + 删除
选择 0 个资源
+