引用发送资源时刷新资源列表和统计

This commit is contained in:
lizanle 2015-09-01 15:03:24 +08:00
parent a78128f5ac
commit 7223e6c91c
5 changed files with 45 additions and 11 deletions

View File

@ -405,7 +405,7 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
@ -436,7 +436,7 @@ class UsersController < ApplicationController
#引入资源列表根据关键词过滤 #引入资源列表根据关键词过滤
def user_ref_resource_search def user_ref_resource_search
search = params[:search].to_s.strip.downcase search = params[:search].to_s.strip.downcase
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
@ -1067,7 +1067,7 @@ class UsersController < ApplicationController
#@user.save_attachments(params[:attachments],User.current) #@user.save_attachments(params[:attachments],User.current)
# Container_type为Principal # Container_type为Principal
Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank?|| params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -1129,7 +1129,7 @@ class UsersController < ApplicationController
end end
end end
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -1268,6 +1268,18 @@ class UsersController < ApplicationController
else else
@flag = false @flag = false
end end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,25
respond_to do |format| respond_to do |format|
format.js format.js
end end
@ -1324,7 +1336,18 @@ class UsersController < ApplicationController
else else
@flag=true @flag=true
end end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,25
respond_to do |format| respond_to do |format|
format.js format.js
end end
@ -1539,7 +1562,7 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+

View File

@ -1,8 +1,8 @@
<% if attachments.nil? || attachments.empty? %> <% if attachments.nil? || attachments.empty? %>
<p class="nodata"> <!--<p class="nodata">-->
<%= l(:label_no_data) %> <!--<%#= l(:label_no_data) %>-->
</p> <!--</p>-->
<% else %> <% else %>
<% attachments.each do |attach| %> <% attachments.each do |attach| %>
<ul class="resourcesList"> <ul class="resourcesList">

View File

@ -1,4 +1,9 @@
<% if @flag == true%> <% if @flag == true%>
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp(); closePopUp();
<% else%> <% else%>
<% end %> <% end %>

View File

@ -1,4 +1,9 @@
<% if @flag == true%> <% if @flag == true%>
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp(); closePopUp();
<% else%> <% else%>
<% end %> <% end %>

View File

@ -146,7 +146,7 @@
var id; //资源id var id; //资源id
var sendType; //发送到课程 1 发送到项目 2 var sendType; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型 var lastSendType; //保存上次发送的发送类型
$(".resourcesList").mousedown(function(e) { $("#resources_list").mousedown(function(e) {
//如果是右键的话 //如果是右键的话
if (3 == e.which) { if (3 == e.which) {
document.oncontextmenu = function() {return false;} document.oncontextmenu = function() {return false;}
@ -160,6 +160,7 @@ $(".resourcesList").mousedown(function(e) {
+ "px; width: 80px;"); + "px; width: 80px;");
$("#contextMenu").show(); $("#contextMenu").show();
//当前光标所在的对象 //当前光标所在的对象
var ele = document.elementFromPoint(pageX,pageY); var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象 //转换为jquery对象
line = $(ele).parent(); line = $(ele).parent();
@ -208,7 +209,7 @@ $(document.body).click(function(e) {
} }
//如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了 //如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了
if( contains($(".resourcesList").get(0),line.get(0))){ if( contains($("#resources_list").get(0),line.get(0))){
line.children().css("background-color", 'white'); line.children().css("background-color", 'white');
} }