From 5aea2250c4ea23cb46ff0d6b515ccbcaa8bbd237 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 13 Nov 2015 10:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8A=A0=E5=85=A5=E6=88=90?= =?UTF-8?q?=E5=91=98=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=94=A8=E6=88=B7=EF=BC=8C=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=BB=99=E5=87=BA=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_member_controller.rb | 16 ++++++++++------ app/views/org_member/create.js.erb | 8 ++++++-- config/locales/zh.yml | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) 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: 您还没有选择用户