diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index fc243741a..6271a6832 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -60,8 +60,12 @@ class MembersController < ApplicationController user_ids.each do |user_id| AppliedProject.deleteappiled(user_id, @project.id) end + @succes_message = "拒绝成功" end end + respond_to do |format| + format.js + end else #modify by nwb #更改课程成员逻辑 @@ -117,9 +121,14 @@ class MembersController < ApplicationController format.html { redirect_to invite_members_project_url(@project) } end else + unless members.present? && members.all? {|m| m.valid? } + @project_error_message = members.empty? ? l(:label_user_role_null) :members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ') + else + @succes_message = "添加成功" + end respond_to do |format| format.html { redirect_to_settings_in_projects } - format.js { @members = members; @applied_members = applied_members; } + format.js format.api { @member = members.first if @member.valid? @@ -184,6 +193,8 @@ class MembersController < ApplicationController end # end of params[:refusal_button] + + end def update diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 406b921ac..8e9802280 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b9d40303b..ab5f0a308 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -128,6 +128,15 @@ module ApplicationHelper end end + def link_to_settings_user(user, options={}) + if user.is_a?(User) + name = h(user.name(options[:format])) + link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "w90 c_orange fl" + else + h(user.to_s) + end + end + #重载上面方法,增加样式显示 def link_to_user_header user,canShowRealName=false,options={} if user.is_a?(User) @@ -574,6 +583,15 @@ module ApplicationHelper s.html_safe end + # li标签checkbos扩展 + def principals_check_box_tags_li(name, principals) + s = '' + principals.each do |principal| + s << "
  • #{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_path( principal.id), :class => "c_blue" }
  • \n" + end + s.html_safe + end + #扩展的checkbox生成 def principals_radio_box_tags_ex(name, principals) s = '' @@ -1352,14 +1370,16 @@ module ApplicationHelper def delete_link(url, options={}) options = { - :method => :delete, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'icon icon-del' + :method => :delete, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'icon icon-del' }.merge(options) link_to l(:button_delete), url, options end + + def delete_new_link(url, options={}) options = { :method => :delete, diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index 5dc5d9542..d1cd3ccd0 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -38,7 +38,7 @@ module MembersHelper links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true } - s + content_tag('ul', links,:class => 'wlist', :style =>"float:left;margin-top:0px;") + s + content_tag('ul', links,:class => 'wlist', :id => "course_member_pagination_links" ) end # add by nwb @@ -55,6 +55,29 @@ module MembersHelper s + content_tag('ul', links,:class => 'wlist',:id => "course_member_pagination_links") end + # 项目配置中添加成员列表 + def render_principals_for_new_project_members(project) + scope = Principal.active.sorted.not_member_of(project).like(params[:q]) + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') + + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true) {|text, parameters, options| + link_to text, appliedproject_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true + } + + s + content_tag('ul', links,:class => 'wlist',:id => "course_member_pagination_links") + end + + # 新申请加入项目成员列表 + def render_principals_for_applied_members_new project + scope = project.applied_projects.map(&:user) + principals = paginateHelper scope,10 + s = content_tag('ul', principals_check_box_tags_li('membership[user_ids][]', principals), :class => 'mb5') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, appliedproject_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true + } + s + content_tag('ul', links,:class => 'wlist', :id => "course_member_pagination_links" ) + end # 当前申请加入的成员名单 def render_principals_for_applied_members(project) diff --git a/app/views/layouts/_base_development_group.html.erb b/app/views/layouts/_base_development_group.html.erb index f8e27a570..87ee4e8d8 100644 --- a/app/views/layouts/_base_development_group.html.erb +++ b/app/views/layouts/_base_development_group.html.erb @@ -47,7 +47,7 @@ <% end %> - + diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb index 5d7c9210e..64e9f64d2 100644 --- a/app/views/layouts/_join_exit_project.html.erb +++ b/app/views/layouts/_join_exit_project.html.erb @@ -10,6 +10,6 @@ <% if ((User.current.member_of? @project) && User.current.login? && User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) %> <%= link_to "#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %> - <%= link_to "#{l(:label_friend_organization)}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%> + <%= link_to "#{text}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%> <% end %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 369fe12e2..30dad5ff7 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -20,21 +20,50 @@ @@ -86,7 +115,8 @@
    - <%= 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} %>
    @@ -133,8 +163,16 @@
  • <%= link_to l(:label_invite_trustie_user), :controller=>"projects", :action=>"invite_members", :id => @project %>
  • <% end %> - - <%= render :partial => 'layouts/base_development_group', :locals => {:project => @project}%> + + + <% if @project.project_new_type == 1 || @project.project_new_type.nil? %> + <%= render :partial => 'layouts/base_development_group', :locals => {:project => @project}%> + <% elsif @project.project_new_type == 2 %> + <%= render :partial => 'layouts/base_research_team', :locals => {:project => @project}%> + <% else %> + <%= render :partial => 'layouts/base_friend_group', :locals => {:project => @project}%> + <% end %> +
    @@ -178,19 +216,18 @@ <%= render :partial => 'layouts/new_footer'%>
    - -
    -
    + <% text = @project.project_new_type == 1 ? "development_group" : (@project.project_new_type == 2 ? "research_group" : "friend_organization")%> +

    请选择项目类型:

    - 确定 + 确定
    @@ -199,7 +236,7 @@ <%= l(:label_loading) %> - <%= call_hook :view_layouts_base_body_bottom %> + <%= call_hook :view_layouts_base_body_bottom %> diff --git a/app/views/members/autocomplete.js.erb b/app/views/members/autocomplete.js.erb index f7f9de151..01faf7da9 100644 --- a/app/views/members/autocomplete.js.erb +++ b/app/views/members/autocomplete.js.erb @@ -2,7 +2,7 @@ <% if @flag == "true"%> $('#principals_for_new_member').html('<%= escape_javascript(render_project_members(@project)) %>'); <% else%> - $('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>'); + $('#principals_for_new_member').html('<%= escape_javascript(render_project_members(@project)) %>'); <% end%> <% elsif @course%> var checked = $("#principals input:checked").size(); diff --git a/app/views/members/create.js.erb b/app/views/members/create.js.erb index 93aad5b5e..61310b22e 100644 --- a/app/views/members/create.js.erb +++ b/app/views/members/create.js.erb @@ -1,27 +1,17 @@ -<%if @project%> -$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); - -<%if !@applied_members%> -<% if @members.present? && @members.all? {|m| m.valid? } %> -<% @members.each do |member| %> -$("#member-<%= member.id %>").effect("highlight"); -<% end %> -<% else %> -<% if @members %> -<% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')%> -alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors || ''))) %>'); -<% else%> -// alert(''); -<% end%> -<% end %> -<% end %> -<%elsif @course%> - <% if @create_member_error_messages%> - alert("<%= @create_member_error_messages%>"); - <% else%> - $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); - alert("添加成功"); - <% end%> -<%end%> - -hideOnLoad(); +<%if @project%> + <% if @project_error_message%> + alert("<%= @project_error_message%>"); + <% else%> + $('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); + hideOnLoad(); + alert("<%= @succes_message%>"); + <% end%> +<%elsif @course%> + <% if @create_member_error_messages%> + alert("<%= @create_member_error_messages%>"); + <% else%> + $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + alert("添加成功"); + <% end%> + hideOnLoad(); +<%end%> diff --git a/app/views/members/destroy.js.erb b/app/views/members/destroy.js.erb index 912cfde58..fcef883ff 100644 --- a/app/views/members/destroy.js.erb +++ b/app/views/members/destroy.js.erb @@ -1,6 +1,7 @@ - <%if @project%> - $('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); - <%elsif @course%> - $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); - <%end%> -hideOnLoad(); + <%if @project%> + $('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); +// $('#tab-content-members').html('<%#= escape_javascript(render :partial => 'projects/settings/members') %>'); + <%elsif @course%> + $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + <%end%> +hideOnLoad(); diff --git a/app/views/members/update.js.erb b/app/views/members/update.js.erb index a166e76ab..2dd2ea9dd 100644 --- a/app/views/members/update.js.erb +++ b/app/views/members/update.js.erb @@ -1,9 +1,8 @@ -<%if @project%> -$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); -$("#member-<%= @member.id %>").effect("highlight"); -<%elsif @course%> -$('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); -<%end%> -hideOnLoad(); - - +<%if @project%> +$('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); +<%elsif @course%> +$('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); +<%end%> +hideOnLoad(); + + diff --git a/app/views/projects/change_project_type.html.erb b/app/views/projects/change_project_type.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/projects/settings/_new_members.html.erb b/app/views/projects/settings/_new_members.html.erb index a38b462e2..0d273fc29 100644 --- a/app/views/projects/settings/_new_members.html.erb +++ b/app/views/projects/settings/_new_members.html.erb @@ -1,67 +1,136 @@ +<%= error_messages_for 'member' %> +<% + roles = Role.givable.all + if @project.project_type == Project::ProjectType_course + roles = roles[3..5] + else + roles = roles[0..2] + end + members = @project.member_principals.includes(:roles, :principal).all.sort +%> +
    - - -
    - + <% if members.any? %> + + <% else %> +

    <%= l(:label_no_data) %>

    + <% end %> + + +<% if roles.any? %>
    -
    -

    +申请加入

    - - -
    - 批准拒绝 - -
    -
    -
    -

    添加成员

    - -
    \ No newline at end of file + <% end %> +
    + +

    <%= l(:label_member_new) %>

    + <%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %> + + <% end%> +
    +<% end %> + + \ No newline at end of file diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index d0c4bd54f..956a725be 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -10,7 +10,7 @@
    <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %>
    - <%= link_to e.user, user_path(e.user), :class => "problem_name c_orange fl" %> <%= l(:label_project_new) %> : + <%= link_to e.user, user_path(e.user), :class => "problem_name c_orange fl" %> <%= l(:label_project_create) %> : <%= link_to e.project.name, :class => "problem_tit fl fb" %>


    <%= l :label_create_time %> :<%= format_time(e.project.created_on) %>

    diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index bbf9cc343..2fb78efde 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -17,6 +17,7 @@ zh: + # # 项目托管平台主页 # @@ -86,7 +87,7 @@ zh: label_project_overview: "项目简介:" label_expend_information: 展开更多信息 - + label_project_create: "新建了项目" # # 项目托管平台 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 0668f152e..6fc7aa8da 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -981,6 +981,7 @@ zh: text_wiki_page_destroy_children: 删除子页面及其所有下级页面 text_wiki_page_reassign_children: 将子页面的上级页面设置为 text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该课程了。你确定要继续吗? + text_own_membership_for_project_confirmation: 你正在删除现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该项目了。你确定要继续吗? text_zoom_in: 放大 text_zoom_out: 缩小 text_applied_project: "用户 %{id} 申请加入项目 %{project}" diff --git a/config/routes.rb b/config/routes.rb index c9220769c..7dc50741d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/public/javascripts/project.js b/public/javascripts/project.js index fe850728c..18d461029 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -14,15 +14,19 @@ function regexName() { } // 项目描述超过展开 -$(function(){ - $(".subNav").click(function(){ - $(this).toggleClass("currentDd").siblings(".subNav").removeClass("currentDd") - $(this).toggleClass("currentDt").siblings(".subNav").removeClass("currentDt") +//$(function(){ +// $(".subNav").click(function(){ +// +// }) +//}) +function expand_tools_expand() +{ + $("#expand_tools_expand").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd"); + $("#expand_tools_expand").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt"); - // 修改数字控制速度, slideUp(500)控制卷起速度 - $(this).next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500); - }) -}) + // 修改数字控制速度, slideUp(500)控制卷起速度 + $("#expand_tools_expand").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500); +} // 描述显示更多信息 function show_more_msg() @@ -184,4 +188,11 @@ function project_setting(n) function submitModules() { $("#modules-form").submit(); +} + +//配置--成员---申请列表--拒绝 +function refusal_applied_member() +{ + $('#new_membership').append(""); + $('#new_membership').submit(); } \ No newline at end of file