diff --git a/app/controllers/org_member_controller.rb b/app/controllers/org_member_controller.rb index 18724882c..4b842f9dc 100644 --- a/app/controllers/org_member_controller.rb +++ b/app/controllers/org_member_controller.rb @@ -10,12 +10,16 @@ class OrgMemberController < ApplicationController def create @org = Organization.find(params[:org]) - member_ids = params[:membership][:user_ids] - role_id = params[:orgRole] - member_ids.each do |user_id| - member = OrgMember.create(:user_id=>user_id) - @org.org_members << member - OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id) + if params[:membership].nil? + @fail_hint = l(:label_blank_user_lists_for_org) + else + member_ids = params[:membership][:user_ids] + role_id = params[:orgRole] + member_ids.each do |user_id| + member = OrgMember.create(:user_id=>user_id) + @org.org_members << member + OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id) + end end respond_to do |format| format.js diff --git a/app/views/org_member/create.js.erb b/app/views/org_member/create.js.erb index d3e8c144e..868dd32b6 100644 --- a/app/views/org_member/create.js.erb +++ b/app/views/org_member/create.js.erb @@ -1,2 +1,6 @@ -$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); -$("#principals_for_new_member").html('') \ No newline at end of file +<% if @fail_hint %> + alert("<%= @fail_hint %>"); +<% else %> + $("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); + $("#principals_for_new_member").html(''); +<% end %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 93775d5ec..694234484 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2091,5 +2091,6 @@ zh: label_language: 语言 label_license: 湘ICP备09019772 label_org_name: 组织名称: + label_blank_user_lists_for_org: 您还没有选择用户