From 6f51118766c8e40546e37da95c4e5acec805a113 Mon Sep 17 00:00:00 2001 From: bsag Date: Thu, 10 Mar 2005 22:40:01 +0000 Subject: [PATCH] Patch submitted by Sean Santry: this adds more useful information to the flash notifications when items are added, deleted or created, by giving you the name of the context, project or next action that you are acting on. Thanks Sean! git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@44 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/context_controller.rb | 16 ++++++++-------- tracks/app/controllers/project_controller.rb | 16 ++++++++-------- tracks/app/controllers/todo_controller.rb | 16 ++++++++-------- tracks/app/views/context/list.rhtml | 2 +- tracks/app/views/project/list.rhtml | 2 +- tracks/app/views/todo/_not_done.rhtml | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index de66c031..f1e9acee 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -26,10 +26,10 @@ class ContextController < ApplicationController context.attributes = @params["new_context"] if context.save - flash["confirmation"] = "Succesfully created context" + flash["confirmation"] = "Succesfully created context \"#{context.name}\"" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't add new context" + flash["warning"] = "Couldn't add new context \"#{context.name}\"" redirect_to( :action => "list" ) end end @@ -46,10 +46,10 @@ class ContextController < ApplicationController @context = Context.find(@params['context']['id']) @context.attributes = @params['context'] if @context.save - flash["confirmation"] = 'Context was successfully updated' + flash["confirmation"] = "Context \"#{@context.name}\" was successfully updated" redirect_to :action => 'list' else - flash["warning"] = 'Context could not be updated' + flash["warning"] = "Context \"#{@context.name}\" could not be updated" redirect_to :action => 'list' end end @@ -78,10 +78,10 @@ class ContextController < ApplicationController back_to = item.context_id if item.save - flash["confirmation"] = "Succesfully added action to context" + flash["confirmation"] = "Succesfully added action \"#{item.description}\" to context" redirect_to( :controller => "context", :action => "show", :id => "#{back_to}" ) else - flash["warning"] = "Could not add action to context" + flash["warning"] = "Could not add action \"#{item.description}\" to context" redirect_to( :controller => "context", :action => "show", :id => "#{back_to}" ) end end @@ -94,10 +94,10 @@ class ContextController < ApplicationController expire_action(:controller => "context", :action => "list") context = Context.find(@params['id']) if context.destroy - flash["confirmation"] = "Succesfully deleted context" + flash["confirmation"] = "Succesfully deleted context \"#{context.name}\"" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't delete context" + flash["warning"] = "Couldn't delete context \"#{context.name}\"" redirect_to( :action => "list" ) end end diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index 071f516f..4f462a3d 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -40,10 +40,10 @@ class ProjectController < ApplicationController @project = Project.find(@params['project']['id']) @project.attributes = @params['project'] if @project.save - flash["confirmation"] = 'Project was successfully updated' + flash["confirmation"] = "Project \"#{@project.name}\" was successfully updated" redirect_to :action => 'list' else - flash["warning"] = 'Project could not be updated' + flash["warning"] = "Project \"#{@project.name}\" could not be updated" redirect_to :action => 'list' end end @@ -58,10 +58,10 @@ class ProjectController < ApplicationController project.name = @params["new_project"]["name"] if project.save - flash["confirmation"] = "Succesfully added project" + flash["confirmation"] = "Succesfully added project \"#{project.name}\"" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't add project" + flash["warning"] = "Couldn't add project \"#{project.name}\"" redirect_to( :action => "list" ) end end @@ -78,10 +78,10 @@ class ProjectController < ApplicationController back_to = item.project_id if item.save - flash["confirmation"] = "Successfully added next action to project" + flash["confirmation"] = "Successfully added next action \"#{item.description}\" to project" redirect_to( :controller => "project", :action => "show", :id => "#{back_to}" ) else - flash["warning"] = "Couldn't add next action to project" + flash["warning"] = "Couldn't add next action \"#{item.description}\" to project" redirect_to( :controller => "project", :action => "show", :id => "#{back_to}" ) end end @@ -91,10 +91,10 @@ class ProjectController < ApplicationController expire_action(:controller => "project", :action => "list") project = Project.find( @params['id'] ) if project.destroy - flash["confirmation"] = "Succesfully deleted project" + flash["confirmation"] = "Succesfully deleted project \"#{project.name}\"" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't delete project" + flash["warning"] = "Couldn't delete project \"#{project.name}\"" redirect_to( :action => "list" ) end end diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index bcbd9326..85d763be 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -59,10 +59,10 @@ class TodoController < ApplicationController @item.attributes = @params["item"] if @item.save - flash["confirmation"] = "Next action was successfully added" + flash["confirmation"] = "Next action \"#{@item.description}\" was successfully added" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't add the action because of an error" + flash["warning"] = "Couldn't add the action \"#{@item.description}\"" redirect_to( :action => "list" ) end end @@ -83,10 +83,10 @@ class TodoController < ApplicationController @item = Todo.find(@params['item']['id']) @item.attributes = @params['item'] if @item.save - flash["confirmation"] = 'Next action was successfully updated' + flash["confirmation"] = "Next action \"#{@item.description}\" was successfully updated" redirect_to :action => 'list' else - flash["warning"] = 'Next action could not be updated' + flash["warning"] = "Next action \"#{@item.description}\" could not be updated" redirect_to :action => 'list' end end @@ -96,10 +96,10 @@ class TodoController < ApplicationController expire_action(:controller => "todo", :action => "list") item = Todo.find(@params['id']) if item.destroy - flash["confirmation"] = "Next action was successfully deleted" + flash["confirmation"] = "Next action \"#{item.description}\" was successfully deleted" redirect_to :action => "list" else - flash["warning"] = "Couldn't delete next action" + flash["warning"] = "Couldn't delete next action \"#{item.description}\"" redirect_to :action => "list" end end @@ -115,10 +115,10 @@ class TodoController < ApplicationController item.toggle!('done') if item.save - flash["confirmation"] = "Next action marked as completed" + flash["confirmation"] = "Next action \"#{item.description}\" marked as completed" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't mark action as completed" + flash["warning"] = "Couldn't mark action \"#{item.description}\" as completed" redirect_to( :action => "list" ) end end diff --git a/tracks/app/views/context/list.rhtml b/tracks/app/views/context/list.rhtml index 77cf3def..1c87caf2 100644 --- a/tracks/app/views/context/list.rhtml +++ b/tracks/app/views/context/list.rhtml @@ -17,7 +17,7 @@ shown <% end %> - <%= link_image_to("edit", { :action => "edit", :id => @context.id }, :title => "Edit item", :size => "10x10") + " " + link_image_to("delete", { :action => "destroy", :id => @context.id }, :title => "Delete item", :size => "10x10", :confirm => "Are you sure you want to delete this context: #{@context.name}. Any todos in this context will be deleted.") + " " %> + <%= link_image_to("edit", { :action => "edit", :id => @context.id }, :title => "Edit item", :size => "10x10") + " " + link_image_to("delete", { :action => "destroy", :id => @context.id }, :title => "Delete item", :size => "10x10", :confirm => "Are you sure you want to delete the context \"#{@context.name}?\" Any todos in this context will be deleted.") + " " %> <% row += 1 %> <% end %> diff --git a/tracks/app/views/project/list.rhtml b/tracks/app/views/project/list.rhtml index a462065d..0c1c1960 100644 --- a/tracks/app/views/project/list.rhtml +++ b/tracks/app/views/project/list.rhtml @@ -10,7 +10,7 @@ <% end %> <%= @project.id.to_s %> <%= link_to ( "#{@project.name}", :action => "show", :id => @project.id ) %> - <%= link_image_to( "edit", { :action => "edit", :id => @project.id }, :title => "Edit item", :size => "10x10" ) + " " + link_image_to( "delete", { :action => "destroy", :id => @project.id }, :title => "Delete item", :size => "10x10", :confirm => "Are you sure you want to delete the project: #{@project.name}. Any todos in this project will be deleted." ) + " " %> + <%= link_image_to( "edit", { :action => "edit", :id => @project.id }, :title => "Edit item", :size => "10x10" ) + " " + link_image_to( "delete", { :action => "destroy", :id => @project.id }, :title => "Delete item", :size => "10x10", :confirm => "Are you sure you want to delete the project \"#{@project.name}?\" Any todos in this project will be deleted." ) + " " %> <% row += 1 %> <% end %> diff --git a/tracks/app/views/todo/_not_done.rhtml b/tracks/app/views/todo/_not_done.rhtml index 53d49622..6f6db0ff 100644 --- a/tracks/app/views/todo/_not_done.rhtml +++ b/tracks/app/views/todo/_not_done.rhtml @@ -3,7 +3,7 @@ <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@notdone_item.id}'" ) %> - <%= link_to( $edit_img, { :action => "edit", :id => @notdone_item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :action => "destroy", :id => @notdone_item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete this entry: #{@notdone_item.description}" ) + " " %> + <%= link_to( $edit_img, { :action => "edit", :id => @notdone_item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :action => "destroy", :id => @notdone_item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete the action \"#{@notdone_item.description}?\"" ) + " " %> <%= due_date( @notdone_item.due ) %> <%= @notdone_item.description %> <% if @notdone_item.project_id %>