2016-12-23 16:58:50 +08:00
|
|
|
$("#all_students_list").empty();
|
|
|
|
<% @users.each do |user|%>
|
|
|
|
var link = "<li id='student_<%=user.id %>'><%=user.show_name %>";
|
|
|
|
<% unless user.user_extensions.student_id == "" %>
|
|
|
|
link += "(<%=user.user_extensions.student_id %>)";
|
|
|
|
<% end %>
|
|
|
|
link += "</li>";
|
|
|
|
$("#all_students_list").append(link);
|
|
|
|
|
|
|
|
var str = $("#group_member_ids").val();
|
|
|
|
var choose_str = "";
|
|
|
|
var lists = $("#choose_students_list li");
|
|
|
|
if(lists.length > 0) {
|
|
|
|
for(var i=0; i<lists.length; i++) {
|
|
|
|
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
|
|
|
|
choose_str += id;
|
|
|
|
if (i != lists.length -1) {
|
|
|
|
choose_str += ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-13 10:30:09 +08:00
|
|
|
<%# if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.contestant_of_contest?(@contest) %>
|
|
|
|
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? %>
|
2016-12-23 16:58:50 +08:00
|
|
|
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
|
2017-03-14 14:35:14 +08:00
|
|
|
$("#student_<%=user.id %>").on("click",function choose_student() {
|
|
|
|
if($("#choose_student_<%=user.id %>").length > 0){
|
|
|
|
$("#choose_member_notice").html("该成员已添加");
|
|
|
|
$("#choose_member_notice").show();
|
|
|
|
} else{
|
|
|
|
$("#choose_member_notice").hide();
|
|
|
|
var li = "<li id='choose_student_<%=user.id %>'";
|
|
|
|
<% if user.id.to_i != User.current.id.to_i %>
|
|
|
|
li += " onclick='delete_student(<%=user.id %>);'";
|
|
|
|
<% end %>
|
|
|
|
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
|
|
|
|
$("#choose_students_list").append(li);
|
|
|
|
}
|
2016-12-23 16:58:50 +08:00
|
|
|
});
|
|
|
|
}
|
2017-03-13 10:30:09 +08:00
|
|
|
<%# elsif !user.contestant_of_contest?(@contest) %>
|
|
|
|
//if (str.indexOf(<%#=user.id.to_s %>) < 0) {
|
|
|
|
// $("#student_<%#=user.id %>").attr("title","该项目成员不是本竞赛的参赛者");
|
|
|
|
//}
|
2016-12-23 16:58:50 +08:00
|
|
|
<% else %>
|
|
|
|
if (str.indexOf(<%=user.id.to_s %>) < 0) {
|
2017-03-14 14:35:14 +08:00
|
|
|
$("#student_<%=user.id %>").on("click",function() {
|
|
|
|
$("#choose_member_notice").html("该成员已加入其它分组");
|
|
|
|
$("#choose_member_notice").show();
|
|
|
|
});
|
|
|
|
} else{
|
|
|
|
$("#student_<%=user.id %>").on("click",function() {
|
|
|
|
$("#choose_member_notice").html("该成员已添加");
|
|
|
|
$("#choose_member_notice").show();
|
|
|
|
});
|
2016-12-23 16:58:50 +08:00
|
|
|
}
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|