Added a warning when a new user or group membership is invalid. #3834

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3934 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Baptiste Barth 2010-08-10 22:37:00 +00:00
parent 83e4cf3dd4
commit 0cfa757db0
2 changed files with 32 additions and 16 deletions

View File

@ -141,14 +141,22 @@ class GroupsController < ApplicationController
@membership = Member.edit_membership(params[:membership_id], params[:membership], @group) @membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
@membership.save if request.post? @membership.save if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } if @membership.valid?
format.js { format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
render(:update) {|page| format.js {
page.replace_html "tab-content-memberships", :partial => 'groups/memberships' render(:update) {|page|
page.visual_effect(:highlight, "member-#{@membership.id}") page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
} page.visual_effect(:highlight, "member-#{@membership.id}")
} }
end }
else
format.js {
render(:update) {|page|
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
}
}
end
end
end end
def destroy_membership def destroy_membership

View File

@ -123,14 +123,22 @@ class UsersController < ApplicationController
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user) @membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
@membership.save if request.post? @membership.save if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } if @membership.valid?
format.js { format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
render(:update) {|page| format.js {
page.replace_html "tab-content-memberships", :partial => 'users/memberships' render(:update) {|page|
page.visual_effect(:highlight, "member-#{@membership.id}") page.replace_html "tab-content-memberships", :partial => 'users/memberships'
} page.visual_effect(:highlight, "member-#{@membership.id}")
} }
end }
else
format.js {
render(:update) {|page|
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
}
}
end
end
end end
def destroy_membership def destroy_membership