课程配置:成员配置处添加搜素成员功能
This commit is contained in:
parent
05c74960a8
commit
8a26fd4343
|
@ -20,7 +20,7 @@ class CoursesController < ApplicationController
|
|||
before_filter :can_show_course, :except => []
|
||||
before_filter :logged_user_by_apptoken,:only => [:show,:new_homework,:feedback]
|
||||
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course,:search_member]
|
||||
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
|
||||
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
||||
before_filter :toggleCourse, :only => [:finishcourse, :restartcourse]
|
||||
|
@ -418,6 +418,21 @@ class CoursesController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def search_member
|
||||
if User.current.allowed_to?(:as_teacher,@course)
|
||||
q = "#{params[:q].strip}"
|
||||
@roles = Role.givable.all[3..5]
|
||||
if q.nil? || q == ""
|
||||
@members = @course.member_principals.includes(:roles, :principal).all.sort
|
||||
else
|
||||
@members = searchmember_by_name(@course.member_principals.includes(:roles, :principal).all.sort,q)
|
||||
end
|
||||
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cs = CoursesService.new
|
||||
@course = cs.create_course(params,User.current)[:course]
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
<div class="search_course fl">
|
||||
<%= form_tag({:controller => 'courses', :action => 'search_member'},:id => "course_member_search_form", :method => :get, :class => "search_form_course",:remote => true) do %>
|
||||
<!-- , :onkeyup => "regexQ('#{l(:label_search_conditions_not_null)}');" -->
|
||||
<%= text_field_tag 'q', params[:q], :placeholder => l(:label_user_name), :class => "search_text fl" %>
|
||||
<a href="javascript:void(0)" onclick="submitMemberSerch('<%= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >
|
||||
<%= l(:label_search)%>
|
||||
</a>
|
||||
<br />
|
||||
<span id="course_member_name_span" style="float: left"></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="members_left">
|
||||
<ul style=" border-bottom:none;">
|
||||
<li>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#course_member_list").html("<%= escape_javascript(render :partial => "courses/member") %>");
|
|
@ -86,4 +86,8 @@ zh:
|
|||
|
||||
#boards
|
||||
label_course_momes_count: "个帖子"
|
||||
#boards count
|
||||
#boards count
|
||||
|
||||
#setting
|
||||
label_user_name: "用户名称"
|
||||
#setting end
|
|
@ -677,6 +677,7 @@ RedmineApp::Application.routes.draw do
|
|||
resources :courses do
|
||||
member do
|
||||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||
get 'search_member', :action => 'search_member'
|
||||
get 'homework', :action => 'homework', :as => 'homework'
|
||||
get 'new_homework', :action => 'new_homework', :as => 'new_homework'
|
||||
get 'file', :action => 'file', :as => 'file'
|
||||
|
|
|
@ -110,7 +110,7 @@ Redmine::AccessControl.map do |map|
|
|||
map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true
|
||||
map.permission :search_course, {:search => :index}, :public => true, :read => true
|
||||
map.permission :add_course, {:courses => [:new, :create]}, :require => :loggedin ,:belong_to_course => true
|
||||
map.permission :edit_course, {:courses => [:settings, :edit, :update]}, :require => :member ,:belong_to_course => true
|
||||
map.permission :edit_course, {:courses => [:settings, :edit, :update,:search_member]}, :require => :member ,:belong_to_course => true
|
||||
map.permission :close_course, {:courses => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_course => true
|
||||
map.permission :select_course_modules, {:courses => :modules}, :require => :member ,:belong_to_course => true
|
||||
map.permission :view_course_journals_for_messages, {:courses => :feedback}, :require => :member,:read => true ,:belong_to_course => true
|
||||
|
|
|
@ -300,6 +300,31 @@ function submitSerch(content)
|
|||
{
|
||||
if(regexName(content)){$("#course_search_form").submit();}
|
||||
}
|
||||
|
||||
//验证搜索时输入名字
|
||||
function regexQ(content)
|
||||
{
|
||||
var name = $.trim($("#q").val());
|
||||
if(name.length == 0)
|
||||
{
|
||||
$("#course_member_name_span").text(content);
|
||||
$("#course_member_name_span").css('color','#ff0000');
|
||||
$("#course_member_name_span").focus();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#course_member_name_span").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//提交课程成员搜索
|
||||
function submitMemberSerch(content)
|
||||
{
|
||||
//if(regexQ(content)){$("#course_member_search_form").submit();}
|
||||
$("#course_member_search_form").submit();
|
||||
}
|
||||
|
||||
//课程描述显示更多信息
|
||||
function show_more_msg()
|
||||
{
|
||||
|
|
|
@ -273,6 +273,8 @@ a:hover.tijiao{ background:#0f99a9;}
|
|||
a.member_btn{ padding: 3px 5px; background:#15bccf; color:#fff;}
|
||||
a:hover.member_btn{ background:#329cbd;}
|
||||
.hol{display: none;}
|
||||
.search_course{margin-top:8px;margin-left:8px;}
|
||||
.search_form_course{margin-top:8px;margin-left:8px;}
|
||||
|
||||
/* 新建项目 */
|
||||
.pro_new{ }
|
||||
|
|
Loading…
Reference in New Issue