完成项目朋友圈、开发组、科研组直接的切换功能

This commit is contained in:
sw 2015-04-14 10:17:42 +08:00
parent f3ba393bd4
commit fadca9128f
5 changed files with 55 additions and 21 deletions

View File

@ -27,15 +27,7 @@ class ProjectsController < ApplicationController
menu_item :feedback, :only => :feedback
menu_item :share, :only => :share
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join,
:course, :enterprise_course, :course_enterprise,:view_homework_attaches]
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close,
:reopen,:view_homework_attaches,:course]
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project]
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
#此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
@ -606,6 +598,17 @@ class ProjectsController < ApplicationController
end
end
#朋友圈、科研组、开发组之间的切换
def change_project_type
@project.project_new_type = params[:project_type]
if @project.save
message = @project.project_new_type
else
message = "0"
end
render :json => message
end
private
def memberAccess

View File

@ -10,6 +10,6 @@
<!--退出项目-->
<% if ((User.current.member_of? @project) && User.current.login? && User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) %>
<%= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %>
<%= link_to "<span class='pr_friend'></span>#{l(:label_friend_organization)}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%>
<%= link_to "<span class='pr_friend'></span>#{text}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%>
<% end %>
</div>

View File

@ -20,21 +20,50 @@
<!--项目的三种类型-->
<script type="text/javascript">
function click_ok()
function click_ok(url)
{
$('#light').css('display','none');
$('#fade').css('display','none');
//
//ajax处理请求
var project_type;
if($("#development_group").attr("checked") == "checked"){
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_development_team)))%>")
$("#project_memu").html('<%= escape_javascript(render(:partial => 'layouts/base_development_group')) %>');
project_type = 1;
}
else if($("#research_group").attr("checked") == "checked"){$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_research_group)))%>");
$("#project_memu").html('<%= escape_javascript(render(:partial => 'layouts/base_research_team')) %>');
else if($("#research_group").attr("checked") == "checked"){
project_type = 2;
}
else if($("#friend_organization").attr("checked") == "checked"){$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_friend_organization)))%>");
$("#project_memu").html('<%= escape_javascript(render(:partial => 'layouts/base_friend_group')) %>');
else if($("#friend_organization").attr("checked") == "checked"){
project_type = 3;
}
$.get(
url,
{ project_type: project_type},
function (data) {
if(data == 1)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_development_team)))%>");
$("#project_memu").html('<%= escape_javascript(render(:partial => 'layouts/base_development_group')) %>');
$("#close_light").attr("onClick","close_window('development_group');");
}
else if(data == 2)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_research_group)))%>");
$("#project_memu").html('<%= escape_javascript(render(:partial => 'layouts/base_research_team')) %>');
$("#close_light").attr("onClick","close_window('research_group');");
}
else if(data == 3)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_friend_organization)))%>");
$("#project_memu").html('<%= escape_javascript(render(:partial => 'layouts/base_friend_group')) %>');
$("#close_light").attr("onClick","close_window('friend_organization');");
}
else
{
alert("服务器异常,请与管理员联系");
}
}
);
}
</script>
</head>
@ -86,7 +115,8 @@
</div>
<!--关注、申请加入/退出项目-->
<div id="join_exit_project_div">
<%= render 'layouts/join_exit_project' %>
<% text = @project.project_new_type == 1 ? l(:label_development_team) : (@project.project_new_type == 2 ? l(:label_research_group) : l(:label_friend_organization))%>
<%= render 'layouts/join_exit_project',{:text => text} %>
</div>
<!-- 项目得分 -->
<div class="cl"></div>
@ -180,8 +210,8 @@
</div><!--Container end-->
<div id="light" class="white_content02">
<!-- 这里写需弹出框的HTML代码 -->
<div ><a href="javascript:void(0)" onClick="close_window('development_group');" class="box_close"></a></div>
<% text = @project.project_new_type == 1 ? "development_group" : (@project.project_new_type == 2 ? "research_group" : "friend_organization")%>
<div ><a href="javascript:void(0)" onClick="close_window('development_group');" class="box_close" id="close_light"></a></div>
<div class=" mt10">
<h3 class="mb10 c_blue">请选择项目类型:</h3>
<ul class="mb10" id="project_type">
@ -189,7 +219,7 @@
<li><input type="radio" name="project_type" id="research_group"/><label >&nbsp;&nbsp;科研组</label></li>
<li><input type="radio" name="project_type" id="friend_organization"/><label >&nbsp;&nbsp;朋友圈</label></li>
</ul>
<a href="javascript:void(0)" class="orange_btn" onclick="click_ok()" >确定</a>
<a href="javascript:void(0)" class="orange_btn" onclick="click_ok('<%= change_project_type_project_path @project%>');" >确定</a>
</div>
</div>

View File

@ -363,6 +363,7 @@ RedmineApp::Application.routes.draw do
end
resources :projects do
member do
match 'change_project_type', :via => [:get, :post]
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
#by young
get 'member', :to => 'projects#member', :as => 'member'