竞赛的子讨论区和子讨论区的配置页面
This commit is contained in:
parent
59853b1558
commit
c36b454c6b
|
@ -261,6 +261,18 @@ class BoardsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
elsif @contest
|
||||
parent = Board.find params[:board_id].to_i
|
||||
board = @contest.boards.build
|
||||
board.name = params[:name]
|
||||
board.description = board.name
|
||||
board.project_id = -1
|
||||
board.course_id = -1
|
||||
board.position = parent.children.count + 1
|
||||
parent.children << board
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -284,7 +296,7 @@ class BoardsController < ApplicationController
|
|||
after_boards = @board.parent.children.where("position > #{@board.position}")
|
||||
after_boards.update_all("position = position - 1")
|
||||
@board.destroy
|
||||
if @course
|
||||
if @course || @contest
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -294,7 +306,7 @@ class BoardsController < ApplicationController
|
|||
end
|
||||
|
||||
def update_position
|
||||
if @course
|
||||
if @course || @contest
|
||||
boards = @board.parent.children
|
||||
if params[:opr] == 'up' && @board.position > 1
|
||||
before_board = boards.where("position = #{@board.position - 1}").first
|
||||
|
@ -314,7 +326,7 @@ class BoardsController < ApplicationController
|
|||
end
|
||||
|
||||
def update_name
|
||||
if @course
|
||||
if @course || @contest
|
||||
@board.update_attribute("name", params[:name])
|
||||
@board.update_attribute("description", params[:name])
|
||||
respond_to do |format|
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
</div>
|
||||
|
||||
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(@board.contest)) %>
|
||||
<%# if is_teacher %>
|
||||
<%#= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %>
|
||||
<%# end %>
|
||||
<% if is_teacher %>
|
||||
<%= link_to "添加子栏目", settings_contest_path(@board.contest.id, :tab => 'boards'), :class => "link-blue fr mt5" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div nhname="topic_form">
|
||||
<% if User.current.logged? %>
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
|
||||
<% course_board = @course.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
|
||||
<% elsif @contest %>
|
||||
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
|
||||
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
|
||||
<% end %>
|
|
@ -2,4 +2,9 @@
|
|||
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
|
||||
<% course_board = @course.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
|
||||
<% elsif @contest %>
|
||||
hideModal();
|
||||
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
|
||||
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
|
||||
<% end %>
|
|
@ -2,4 +2,9 @@
|
|||
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
|
||||
<% course_board = @course.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
|
||||
<% elsif @contest %>
|
||||
hideModal();
|
||||
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
|
||||
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
|
||||
<% end %>
|
|
@ -2,4 +2,8 @@
|
|||
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
|
||||
<% course_board = @course.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
|
||||
<% elsif @contest %>
|
||||
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
|
||||
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
|
||||
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
|
||||
<% end %>
|
|
@ -1,12 +1,18 @@
|
|||
<% board = @contest.boards.where("parent_id is NULL").first %>
|
||||
<div class="pro_new_setting_conbox" style="width:100%; border:none;">
|
||||
<div class=" sy_new_tchbox clear " style="margin-left:10px; margin-right:10px; " >
|
||||
<div class="sy_new_tchbox clear undis" style="margin-left:10px; margin-right:10px;" id="add_sub_board">
|
||||
<%= form_tag url_for(:controller => 'boards', :action => 'create', :contest_id => @contest.id, :board_id => board.id), :id=> 'add_board_form_subboard',:remote => true do %>
|
||||
<ul class="pro_newsetting_con mb15">
|
||||
<li class="mb10 clear">
|
||||
<label class="fl">新增子栏目名称 : </label>
|
||||
<input type="text" class="w695 fl" placeholder=" 请输入子栏目名称">
|
||||
<input id="subfield_name" name="name" placeholder="请输入子栏目名称" maxlength="30" class="w695 fl h28" type="text">
|
||||
<div class="cl"></div>
|
||||
<span id="new_notice" class="undis ml10 fl c_red">名称不能为空</span>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="javascript:void(0);" class="fr sy_btn_grey ">取消</a><a href="javascript:void(0);" class="fr sy_btn_blue mr5">保存</a>
|
||||
<a href="javascript:void(0);" class="fr sy_btn_grey" onclick="$('#add_sub_board').toggle();">取消</a>
|
||||
<a href="javascript:void(0);" class="fr sy_btn_blue mr5" id="subMenuSubmit">保存</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clear ml10 mr10">
|
||||
<table class="sy_new_table clearfix mb15" cellpadding="0" cellspacing="0">
|
||||
|
@ -18,23 +24,85 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml20"></span>竞赛讨论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_green mr5 ">添加子栏目</a></th>
|
||||
<td class="game-text-left"><span class="ml20"></span>竞赛讨论区</td>
|
||||
<td class="game-text-right"><a href="javascript:void(0);" class="sy_btn_green mr5" onclick="$('#add_sub_board').toggle();">添加子栏目</a></td>
|
||||
</tr>
|
||||
<% count = board.children.count %>
|
||||
<% board.children.reorder("position asc").each_with_index do |board, i|%>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml40"></span>技术讨论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">下移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
|
||||
<td class="game-text-left">
|
||||
<div id="board_sub_show_<%= board.id %>" class="ml40 w350 hidden" title="<%=board.name %>"><%=board.name %></div>
|
||||
<div id="board_sub_edit_<%= board.id %>" style="display:none;" class="ml40">
|
||||
<input type="text" name="name" class="h28 w300" id="board_sub_name_<%=board.id %>" onblur="update_sub_board_name('#board_sub_show_<%= board.id %>','#board_sub_edit_<%= board.id %>','<%= board.id %>','<%= @contest.id %>',$(this).val());" value="<%= board.name %>"/>
|
||||
</div>
|
||||
</td>
|
||||
<td class="game-text-right">
|
||||
<% unless i == 0 %>
|
||||
<%= link_to('上移', {:controller => 'boards', :action => 'update_position', :id => board.id, :contest_id => @contest.id, :opr => 'up'},:remote => true, :method => 'post', :class => "sy_btn_blue mr5", :title => '上移') %>
|
||||
<% end %>
|
||||
<% if i < count - 1 %>
|
||||
<%= link_to('下移', {:controller => 'boards', :action => 'update_position', :id => board.id, :contest_id => @contest.id, :opr => 'down'},:remote => true, :method => 'post', :class => "sy_btn_blue mr5", :title => '下移') %>
|
||||
<% end %>
|
||||
<a href="javascript:void(0);" class="sy_btn_blue mr5" onclick="edit('#board_sub_show_<%= board.id %>','#board_sub_edit_<%= board.id %>');">编辑</a>
|
||||
<a href="javascript:void(0);" class="sy_btn_blue mr5" onclick="delete_confirm_box_2('<%=contest_board_path(board, :contest_id => @contest.id) %>', '确定要删除<%=board.name %>吗?')">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml40"></span>学术论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">上移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">下移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml40"></span>学术论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">上移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
$("#subMenuSubmit").one('click', function(){
|
||||
sub_board_submit();
|
||||
});
|
||||
});
|
||||
function sub_board_submit(){
|
||||
if ($("#subfield_name").val().trim() != ""){
|
||||
$("#new_notice").hide();
|
||||
$("#add_board_form_subboard").submit();
|
||||
} else {
|
||||
$("#new_notice").show();
|
||||
$("#subMenuSubmit").one('click', function(){
|
||||
sub_board_submit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function update_sub_board_name(show_id, edit_id, field_id, domain_id, input_value) {
|
||||
if (input_value.trim() != "" && $(show_id).html().trim() != input_value.trim()) {
|
||||
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
||||
'<div class="clear mt15"><p class="text_c f16 fontGrey7">确定修改为' + input_value + '?</p><div class="cl"></div><a href="javascript:void(0)" class="fr sy_btn_blue mt10"' +
|
||||
' style="margin-right: 92px;" onclick="update_confirm(1,' + field_id + ',' + domain_id + ');">确定</a>'+
|
||||
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="update_confirm(2,' + field_id + ',' + domain_id + ');">取消</a></div></div>';
|
||||
pop_box_new(htmlvalue, 300, 140);
|
||||
}
|
||||
$(show_id).show();
|
||||
$(edit_id).hide();
|
||||
}
|
||||
|
||||
function update_confirm(type, field_id, domain_id){
|
||||
if(type == 1){
|
||||
$.ajax({
|
||||
url: "/boards/" + field_id + "/update_name?contest_id=" + domain_id + "&name=" + $("#board_sub_name_"+field_id).val(),
|
||||
type: 'put'
|
||||
});
|
||||
} else {
|
||||
hideModal();
|
||||
$("#board_sub_edit_"+field_id).children("input").val($("#board_sub_show_"+field_id).html().trim());
|
||||
}
|
||||
}
|
||||
|
||||
function edit(show_id, edit_id) {
|
||||
$(show_id).toggle();
|
||||
$(edit_id).toggle();
|
||||
$(edit_id).find('input').focus();
|
||||
$(edit_id).find('input').on('keypress', function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
this.blur();
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
|
@ -1,8 +1,8 @@
|
|||
<table class="sy_new_table clearfix mb15" cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th style="width:320px;">用户</th>
|
||||
<th style="width: 35px;">序号</th>
|
||||
<th style="width:320px;">姓名</th>
|
||||
<th>角色</th>
|
||||
<th class="sy_new_namebox">操作</th>
|
||||
</tr>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<li id="game-setting-tab-nav-2" onclick="HoverLi(2);">
|
||||
<a href="javascript:void(0);">成员</a>
|
||||
</li>
|
||||
<li id="game-setting-tab-nav-3" >
|
||||
<!--<a href="javascript:void(0);" >讨论区设置</a>-->
|
||||
<li id="game-setting-tab-nav-3" onclick="HoverLi(3);">
|
||||
<a href="javascript:void(0);">讨论区设置</a>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
|
@ -33,6 +33,8 @@
|
|||
$(function(){
|
||||
<% if @select_tab == 'member'%>
|
||||
$("#game-setting-tab-nav-2").click();
|
||||
<% elsif @select_tab == 'boards'%>
|
||||
$("#game-setting-tab-nav-3").click();
|
||||
<% end %>
|
||||
});
|
||||
function g(o){
|
||||
|
@ -44,7 +46,7 @@
|
|||
g('game-setting-tab-nav-'+i).className='game-setting-nav-nomall';
|
||||
g('game-setting-content-'+i).className='undis';
|
||||
}
|
||||
g('game-setting-content-'+n).className='dis';
|
||||
g('game-setting-content-'+n).className='game-dis';
|
||||
g('game-setting-tab-nav-'+n).className='game-setting-nav-hover';
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<ul class="sub-menu">
|
||||
<% course_board.children.reorder("position asc").each do |board| %>
|
||||
<li id="board_children_<%=board.id %>">
|
||||
<% count = board ? (board.topics.count + Message.where("board_id =? and parent_id is not ?", board.id, nil).count) : 0 %>
|
||||
<% count = board ? board.messages.count : 0 %>
|
||||
<a href="<%=course_boards_path(@course, :board_id =>board.id) %>"><font class="hidden dis" style="max-width: 120px;"><%=board.name %></font><span style="vertical-align: top;"><%=count %></span></a>
|
||||
<% if User.current.logged? %>
|
||||
<%= link_to( "",course_boards_path(@course, :board_id =>board.id, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") %>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<% is_admin = User.current.admin? || User.current.admin_of_contest?(@contest) %>
|
||||
<% unless contest_board.children.empty? %>
|
||||
<ul class="sub-menu">
|
||||
<% contest_board.children.reorder("position asc").each do |board| %>
|
||||
<li id="board_children_<%=board.id %>">
|
||||
<% count = board ? board.messages.count : 0 %>
|
||||
<a href="<%=contest_boards_path(@contest, :board_id =>board.id) %>">
|
||||
<font class="hidden dis" style="max-width: 120px;"><%=board.name %></font>
|
||||
<span style="vertical-align: top;"><%=count %></span>
|
||||
</a>
|
||||
<% if User.current.logged? && is_admin %>
|
||||
<%= link_to( "",contest_boards_path(@contest, :board_id =>board.id, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
|
@ -45,11 +45,15 @@
|
|||
<a href="<%= works_path(:contest => @contest.id,:is_new => 1) %>" class="sy_class_add"></a>
|
||||
<% end %>
|
||||
</li>
|
||||
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
|
||||
<li id="sy_04" class="sy_icons_boards">
|
||||
<% count = @contest.boards.first ? (@contest.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @contest.boards.first.id, nil).count) : 0 %>
|
||||
<% count = contest_board ? contest_board.messages.count : 0 %>
|
||||
<a href="<%=contest_boards_path(@contest) %>">讨论区<span><%=count %></span></a>
|
||||
<%= link_to( "",contest_boards_path(@contest, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") if is_admin %>
|
||||
</li>
|
||||
<div id="board_children_list">
|
||||
<%= render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board} %>
|
||||
</div>
|
||||
<li id="sy_05" class="sy_icons_news">
|
||||
<%= link_to "通知<span>#{@contest.news.count}</span>".html_safe, contest_news_index_path(@contest), :class => "sy_icons_feedback" %>
|
||||
<% if is_admin %>
|
||||
|
|
|
@ -65,9 +65,9 @@
|
|||
</li>
|
||||
<% end %>
|
||||
<% course_board = @course.boards.where("parent_id is NULL").first %>
|
||||
<% unless show_nav?(course_board ? course_board.topics.count : 0) %>
|
||||
<% unless show_nav?(course_board ? course_board.messages.count : 0) %>
|
||||
<li id="sy_02" class="sy_icons_boards">
|
||||
<% count = course_board ? (course_board.topics.count + Message.where("board_id =? and parent_id is not ?", course_board.id, nil).count) : 0 %>
|
||||
<% count = course_board ? course_board.messages.count : 0 %>
|
||||
<a href="<%=course_boards_path(@course) %>">讨论区<span><%=count %></span></a>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") if User.current.logged? %>
|
||||
</li>
|
||||
|
|
|
@ -27,11 +27,11 @@ p.pro_new_grey{ line-height: 1.9; }
|
|||
.game-setting-nav-hover{border-bottom:3px solid #3498db; font-weight:bold; }
|
||||
.game-setting-nav-nomall {border-bottom:none; }
|
||||
.undis {display:none;}
|
||||
.dis {display:block;}
|
||||
.game-dis {display:block;}
|
||||
/* 竞赛*/
|
||||
.banner-game { width: 968px; height: 110px;}
|
||||
.game-text-right{ text-align: right;}
|
||||
.game-text-left{ text-align: left;}
|
||||
.sy_new_table tbody tr td.game-text-right{ text-align: right;}
|
||||
.sy_new_table tbody tr td.game-text-left{ text-align: left;}
|
||||
.game-setting-h3{ width: 100%; height: 40px; line-height: 40px; font-size: 14px; color: #666; font-weight: normal; background: #fff; border-bottom: 10px solid #eaebec;}
|
||||
.w695{width: 695px; }
|
||||
.w625{width: 625px; }
|
||||
|
|
Loading…
Reference in New Issue