diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d9219d50e..d1979bc84 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1549,43 +1549,39 @@ class UsersController < ApplicationController user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} @user = User.find(params[:id]) - #@user.save_attachments(params[:attachments],User.current) - # Container_type为Principal + # 保存文件 attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true) + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_course_ids = User.current.courses.map { |c| c.id} + user_project_ids = User.current.projects.map {|p| p.id} + # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - if params[:status] == 2 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id], params[:order] + @attachments = get_attch_resources(params[:id], @order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources params[:id], params[:order] + @attachments = get_principal_resources(params[:id], @order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id], params[:order] - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids, params[:order]) + @attachments = get_course_resources_public( user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids, params[:order]) + @attachments = get_project_resources_public(user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources_public params[:order] + @attachments = get_attch_resources_public(@order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources_public params[:order] + @attachments = get_principal_resources_public(@order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end end @status = params[:status] @@ -1611,43 +1607,38 @@ class UsersController < ApplicationController Attachment.where("author_id = #{User.current.id}").delete(id) end end + @user = User.current + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - if params[:status] == 2 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id], params[:order] + @attachments = get_attch_resources(params[:id], @order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources params[:id], params[:order] + @attachments = get_principal_resources(params[:id], @order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id], params[:order] - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids, params[:order]) + @attachments = get_course_resources_public( user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids, params[:order]) + @attachments = get_project_resources_public(user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources_public params[:order] + @attachments = get_attch_resources_public(@order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources_public params[:order] + @attachments = get_principal_resources_public(@order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end end @status = params[:status] @@ -2478,13 +2469,13 @@ class UsersController < ApplicationController end elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids, params[:order], @score) + @attachments = get_course_resources_public( user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids, params[:order], @score) + @attachments = get_project_resources_public(user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources_public(params[:order], @score) + @attachments = get_attch_resources_public(@order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources_public(params[:order], @score) + @attachments = get_principal_resources_public(@order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) diff --git a/app/views/users/user_resource.js.erb b/app/views/users/user_resource.js.erb index 0ed47c01b..2fa0035b2 100644 --- a/app/views/users/user_resource.js.erb +++ b/app/views/users/user_resource.js.erb @@ -9,7 +9,6 @@ $("#res_all_count").html(<%= @atta_count %>); $("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); $("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); - $("#resource_type_all").attr('href','<%= user_resource_user_path(@user, :type => @type, :status => 1) %>'); $("#resource_type_course").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 2) %>'); $("#resource_type_project").attr('href','<%= user_resource_user_path(@user,:type => @type, :status => 3) %>'); diff --git a/app/views/users/user_resource_create.js.erb b/app/views/users/user_resource_create.js.erb index 5ce547fbf..e818f2870 100644 --- a/app/views/users/user_resource_create.js.erb +++ b/app/views/users/user_resource_create.js.erb @@ -1,6 +1,15 @@ closeModal(); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); -//这里不能将翻页的更新 -$("#res_all_count").html('<%= @atta_count%>'); +$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#res_all_count").html(<%= @atta_count%>); $("#res_count").html(0); -$("#checkboxAll").attr('checked',false); \ No newline at end of file +$("#checkboxAll").attr('checked',false); +//更新状态 +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); +$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>'); \ No newline at end of file diff --git a/app/views/users/user_resource_delete.js.erb b/app/views/users/user_resource_delete.js.erb index e16abf28d..9583274c6 100644 --- a/app/views/users/user_resource_delete.js.erb +++ b/app/views/users/user_resource_delete.js.erb @@ -1,5 +1,14 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#res_all_count").html('<%= @atta_count%>') +$("#res_all_count").html(<%= @atta_count%>); $("#res_count").html(0); -$("#checkboxAll").attr('checked',false); \ No newline at end of file +$("#checkboxAll").attr('checked',false); +//更新状态 +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); +$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>'); \ No newline at end of file