diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 0d22ab461..4277b5976 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -175,4 +175,40 @@ class OrganizationsController < ApplicationController format.js end end + + def join_course_menu + @organization = Organization.find(params[:id]) + respond_to do |format| + format.js + end + end + + def search_courses + @organization = Organization.find(params[:id]) + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + #sql = "select courses.* from courses inner join members on courses.id = members.course_id inner join org_courses on courses.id = org_courses.course_id where org_courses.organization_id != #{@organization.id} and members.user_id = #{User.current.id} and courses.name like '#{condition}'" + sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'" + user_courses = Course.find_by_sql(sql) + @added_course_ids = @organization.courses.map(&:id) + @courses = [] + user_courses.each do |course| + if @added_course_ids.include?(course.id) + @courses << course + end + end + end + + def join_courses + @organization = Organization.find(params[:id]) + course_ids = params[:courseNames] + course_ids.each do |id| + OrgCourse.create(:organization_id => @organization.id, :course_id => id.to_i, :created_at => Time.now) + end + respond_to do |format| + format.js + end + end end diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 84edf02e1..7c55060b4 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -98,6 +98,18 @@
课程 +
+ +
@@ -122,9 +134,20 @@
+ + + + diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb new file mode 100644 index 000000000..36894d92e --- /dev/null +++ b/app/views/organizations/_join_course_menu.html.erb @@ -0,0 +1,98 @@ + + + + + + + + + + + + + +
+
+
请选择关联到组织的课程
+
+
+
+ <%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %> + +
+
+ 关联 +
+ + <% end %> +
+ +
+
+
+
+
+ + + + diff --git a/app/views/organizations/join_course_menu.js.erb b/app/views/organizations/join_course_menu.js.erb new file mode 100644 index 000000000..95b9f282f --- /dev/null +++ b/app/views/organizations/join_course_menu.js.erb @@ -0,0 +1,12 @@ +$('#topnav_course_menu').hide(); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_course_menu', :locals => {:organization_id => @organization.id}) %>'); +$('#ajax-modal').show(); +//showModal('ajax-modal', '540px'); +//$('#ajax-modal').css('height','390px'); +////$('#ajax-modal').siblings().remove(); +////$('#ajax-modal').siblings().hide(); +//$('#ajax-modal').before("" + +// ""); +//$('#ajax-modal').parent().removeClass("alert_praise"); +//$('#ajax-modal').parent().css("top","").css("left",""); +//$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/organizations/search_courses.js.erb b/app/views/organizations/search_courses.js.erb new file mode 100644 index 000000000..9e92b4b07 --- /dev/null +++ b/app/views/organizations/search_courses.js.erb @@ -0,0 +1,9 @@ +$("#search_courses_result_list").html(""); +$("#search_courses_result_list").append('') + diff --git a/config/routes.rb b/config/routes.rb index d137553ad..f8f0e1cc1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,9 @@ RedmineApp::Application.routes.draw do get 'members' get 'more_org_projects' get 'more_org_courses' + get 'search_courses' + post 'join_course_menu' + post 'join_courses' end collection do get 'check_uniq' diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index d18dd27d8..bedfa1ceb 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -384,6 +384,7 @@ a.resourcesGrey:hover {font-size:12px; color:#269ac9;} a.uploadText {color:#ffffff; font-size:14px;} .resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:left; background-color:#ffffff;} .searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;} +.searchCourse {border:none; outline:none; background-color:#ffffff; width:184px; padding-left:10px; display:block; margin-bottom:15px;} .searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;} /*.resourcesSearchBanner {height:34px; margin-bottom:10px;}*/ .resourcesSearchBanner {width:710px; height:34px; margin-bottom:10px; margin-top:15px; margin-left:auto; margin-right:auto;} diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 914df16b5..0a578ccc3 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -44,6 +44,7 @@ a.cancelBtn:hover {background-color:#717171; color:#ffffff;} .relatedListName {width:240px; text-align:left; max-width:240px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;} .relatedListOption {width:80px; text-align:center;} .relateOrgName {width:240px; max-width:240px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;color:#656565;} +.search_org {width:150px; max-width:200px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;color:#656565;} /*组织列表*/ .mt28 {margin-top:28px;}