Applied the flash notices patch by Matt Jones (slightly edited).

flash[:notice] and flash[:error] are now used for notice/error messages.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@600 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-08-02 17:42:20 +00:00
parent 7701de9ae4
commit 2d5ac54d2e
16 changed files with 44 additions and 21 deletions

View File

@ -54,7 +54,7 @@ class AccountController < ApplicationController
end end
redirect_back_or_default :controller => 'my', :action => 'page' redirect_back_or_default :controller => 'my', :action => 'page'
else else
flash.now[:notice] = l(:notice_account_invalid_creditentials) flash.now[:error] = l(:notice_account_invalid_creditentials)
end end
end end
end end
@ -89,9 +89,9 @@ class AccountController < ApplicationController
if request.post? if request.post?
user = User.find_by_mail(params[:mail]) user = User.find_by_mail(params[:mail])
# user not found in db # user not found in db
flash.now[:notice] = l(:notice_account_unknown_email) and return unless user flash.now[:error] = l(:notice_account_unknown_email) and return unless user
# user uses an external authentification # user uses an external authentification
flash.now[:notice] = l(:notice_can_t_change_password) and return if user.auth_source_id flash.now[:error] = l(:notice_can_t_change_password) and return if user.auth_source_id
# create a new token for password recovery # create a new token for password recovery
token = Token.new(:user => user, :action => "recovery") token = Token.new(:user => user, :action => "recovery")
if token.save if token.save

View File

@ -66,7 +66,7 @@ class CustomFieldsController < ApplicationController
@custom_field = CustomField.find(params[:id]).destroy @custom_field = CustomField.find(params[:id]).destroy
redirect_to :action => 'list', :tab => @custom_field.type redirect_to :action => 'list', :tab => @custom_field.type
rescue rescue
flash[:notice] = "Unable to delete custom field" flash[:error] = "Unable to delete custom field"
redirect_to :action => 'list' redirect_to :action => 'list'
end end
end end

View File

@ -64,7 +64,7 @@ class EnumerationsController < ApplicationController
flash[:notice] = l(:notice_successful_delete) flash[:notice] = l(:notice_successful_delete)
redirect_to :action => 'list' redirect_to :action => 'list'
rescue rescue
flash[:notice] = "Unable to delete enumeration" flash[:error] = "Unable to delete enumeration"
redirect_to :action => 'list' redirect_to :action => 'list'
end end
end end

View File

@ -30,7 +30,7 @@ class IssueCategoriesController < ApplicationController
@category.destroy @category.destroy
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
rescue rescue
flash[:notice] = "Categorie can't be deleted" flash[:error] = "Categorie can't be deleted"
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
end end

View File

@ -79,7 +79,7 @@ class IssueStatusesController < ApplicationController
IssueStatus.find(params[:id]).destroy IssueStatus.find(params[:id]).destroy
redirect_to :action => 'list' redirect_to :action => 'list'
rescue rescue
flash[:notice] = "Unable to delete issue status" flash[:error] = "Unable to delete issue status"
redirect_to :action => 'list' redirect_to :action => 'list'
end end
end end

View File

@ -69,7 +69,7 @@ class IssuesController < ApplicationController
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
# Optimistic locking exception # Optimistic locking exception
flash[:notice] = l(:notice_locking_conflict) flash[:error] = l(:notice_locking_conflict)
end end
end end
end end
@ -118,7 +118,7 @@ class IssuesController < ApplicationController
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
# Optimistic locking exception # Optimistic locking exception
flash[:notice] = l(:notice_locking_conflict) flash[:error] = l(:notice_locking_conflict)
end end
end end
@assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user } @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }

View File

@ -62,7 +62,7 @@ class MyController < ApplicationController
# Change user's password # Change user's password
def change_password def change_password
@user = self.logged_in_user @user = self.logged_in_user
flash[:notice] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id
if @user.check_password?(params[:password]) if @user.check_password?(params[:password])
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if @user.save if @user.save
@ -72,7 +72,7 @@ class MyController < ApplicationController
return return
end end
else else
flash[:notice] = l(:notice_account_wrong_password) flash[:error] = l(:notice_account_wrong_password)
end end
redirect_to :action => 'account' redirect_to :action => 'account'
end end

View File

@ -227,7 +227,7 @@ class ProjectsController < ApplicationController
default_status = IssueStatus.default default_status = IssueStatus.default
unless default_status unless default_status
flash.now[:notice] = 'No default issue status defined. Please check your configuration.' flash.now[:error] = 'No default issue status defined. Please check your configuration.'
render :nothing => true, :layout => true render :nothing => true, :layout => true
return return
end end

View File

@ -128,7 +128,7 @@ private
end end
def show_error def show_error
flash.now[:notice] = l(:notice_scm_error) flash.now[:error] = l(:notice_scm_error)
render :nothing => true, :layout => true render :nothing => true, :layout => true
end end

View File

@ -58,7 +58,7 @@ class RolesController < ApplicationController
def destroy def destroy
@role = Role.find(params[:id]) @role = Role.find(params[:id])
unless @role.members.empty? unless @role.members.empty?
flash[:notice] = 'Some members have this role. Can\'t delete it.' flash[:error] = 'Some members have this role. Can\'t delete it.'
else else
@role.destroy @role.destroy
end end

View File

@ -73,7 +73,7 @@ class TrackersController < ApplicationController
def destroy def destroy
@tracker = Tracker.find(params[:id]) @tracker = Tracker.find(params[:id])
unless @tracker.issues.empty? unless @tracker.issues.empty?
flash[:notice] = "This tracker contains issues and can\'t be deleted." flash[:error] = "This tracker contains issues and can\'t be deleted."
else else
@tracker.destroy @tracker.destroy
end end

View File

@ -114,7 +114,7 @@ class UsersController < ApplicationController
User.find(params[:id]).destroy User.find(params[:id]).destroy
redirect_to :action => 'list' redirect_to :action => 'list'
rescue rescue
flash[:notice] = "Unable to delete user" flash[:error] = "Unable to delete user"
redirect_to :action => 'list' redirect_to :action => 'list'
end end
end end

View File

@ -30,7 +30,7 @@ class VersionsController < ApplicationController
@version.destroy @version.destroy
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
rescue rescue
flash[:notice] = "Unable to delete version" flash[:error] = "Unable to delete version"
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
end end

View File

@ -73,7 +73,7 @@ class WikiController < ApplicationController
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
# Optimistic locking exception # Optimistic locking exception
flash[:notice] = l(:notice_locking_conflict) flash[:error] = l(:notice_locking_conflict)
end end
# show page history # show page history

View File

@ -138,7 +138,8 @@
</div> </div>
<div id="content"> <div id="content">
<% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %> <%= content_tag('div', flash[:error], :id => 'flash', :class => 'error') if flash[:error] %>
<%= content_tag('div', flash[:notice], :id => 'flash', :class => 'notice') if flash[:notice] %>
<%= yield %> <%= yield %>
</div> </div>

View File

@ -695,3 +695,25 @@ background-image: url(../images/loading.gif);
padding-left: 26px; padding-left: 26px;
vertical-align: bottom; vertical-align: bottom;
} }
/***** Flash messages ****/
#flash {
padding: 4px 4px 4px 30px;
margin-bottom: 16px;
font-size: 1.2em;
border: 2px solid;
}
#flash.error {
background: url(../images/false.png) 8px 50% no-repeat;
background-color: #ffe3e3;
border-color: #dd0000;
color: #550000;
}
#flash.notice {
background: url(../images/true.png) 8px 50% no-repeat;
background-color: #dfffdf;
border-color: #9fcf9f;
color: #005f00;
}