diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index bd3998621..b650afe1b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -66,6 +66,7 @@ class ProjectsController < ApplicationController helper :words helper :project_score helper :user_score + include UsersHelper ### added by william include ActsAsTaggableOn::TagsHelper diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 803dd49d3..8b1e344ed 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2205,6 +2205,37 @@ class UsersController < ApplicationController end end + # 导入资源 + def import_resources + # 别人的资源库是没有权限去看的 + if User.current.id.to_i != params[:id].to_i + render_403 + return + end + 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") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + elsif params[:type] == "6" # 公共资源 + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids) + end + @type = params[:type] + @limit = 25 + @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| + format.js + format.html {render :layout => 'new_base'} + end + end + # 根据资源关键字进行搜索 def resource_search search = "%#{params[:search].strip.downcase}%" diff --git a/app/views/files/_import_files.html.erb b/app/views/files/_import_files.html.erb new file mode 100644 index 000000000..168cea962 --- /dev/null +++ b/app/views/files/_import_files.html.erb @@ -0,0 +1,138 @@ +<%#= render :partial => 'users/user_resource_info' %> +
选用资源库中的资源
+
公共资源 我的资源 + +
+
+ + + + + + + + + + + +
+
选用
+
取消
+
+ + + + + + + +
+
+
+
diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index e8f4f023b..49f31355d 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -62,10 +62,12 @@ <%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search",:remote=>true) do %> <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> <%= submit_tag "项目内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()", :style =>"width:72px;" %> - <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <%#= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> <% if User.current.member_of?(@project) %> + <%= link_to("导入资源", import_resources_user_path(User.current), :class => "blue-btn fr mr5", :remote => true) %> + <% end %> <% end %> diff --git a/app/views/users/import_resources.js.erb b/app/views/users/import_resources.js.erb new file mode 100644 index 000000000..3a932d366 --- /dev/null +++ b/app/views/users/import_resources.js.erb @@ -0,0 +1,10 @@ +$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/resource_search_form', :locals => {:user => User.current, :type => 1} ) %>'); +$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/resources_list' , :locals => { :attachments => @attachments}) %>'); +$('#ajax-modal').html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +showModal('ajax-modal', '513px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","40%").css("left","36%").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); + + diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index d8d7d7dc7..69122aaba 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -76,7 +76,7 @@ 公共资源
  • - 我的资源 + 我的资源
  •  
  • diff --git a/app/views/users/user_resource.js.erb b/app/views/users/user_resource.js.erb index 48f10d277..725b91b80 100644 --- a/app/views/users/user_resource.js.erb +++ b/app/views/users/user_resource.js.erb @@ -1,5 +1,5 @@ $("#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})%>'); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' , :locals => { :attachments => @attachments}) %>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); diff --git a/config/routes.rb b/config/routes.rb index 7754365ad..e6de40fc5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -535,6 +535,7 @@ RedmineApp::Application.routes.draw do match 'user_act_issue_assign_to', :to => 'users#user_act_issue_assign_to', :via => [:get, :post] get 'edit_brief_introduction' get "user_resource" + get "import_resources" get "resource_search" post "user_resource_create" post "user_resource_delete" diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 8c2d88e5a..2acf87909 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -995,6 +995,8 @@ span.at a{color:#269ac9;text-decoration: none;} .researchBox { width:240px; height:24px; border:1px solid #dddddd; color:#666666; outline:none;} .blueBtn{ width:60px; height:26px; color:#FFF; border:none; background-color:#269ac9; cursor:pointer; padding-left:0px; text-align:center;} .blueBtn:hover {background-color:#298fbd;} +a.blue-btn{ padding:4px 7px; color:#FFF; border:none; background-color:#269ac9; cursor:pointer; text-align:center;} +a.blue-btn:hover {background-color:#298fbd;} /*文本描述展开高度*/ .maxh360 {max-height: 810px;}