diff --git a/tracks/app/controllers/contexts_controller.rb b/tracks/app/controllers/contexts_controller.rb index efb3e297..9f5dd721 100644 --- a/tracks/app/controllers/contexts_controller.rb +++ b/tracks/app/controllers/contexts_controller.rb @@ -4,6 +4,7 @@ class ContextsController < ApplicationController before_filter :init, :except => [:create, :destroy, :order] before_filter :init_todos, :only => :show + before_filter :check_user_set_context, :only => [:update, :destroy] skip_before_filter :login_required, :only => [:index] prepend_before_filter :login_or_feed_token_required, :only => [:index] session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) } @@ -69,7 +70,6 @@ class ContextsController < ApplicationController # Edit the details of the context # def update - check_user_set_context params['context'] ||= {} success_text = if params['field'] == 'name' && params['value'] params['context']['id'] = params['id'] @@ -92,12 +92,10 @@ class ContextsController < ApplicationController # If the context contains actions, you'll get a warning dialogue. # If you choose to go ahead, any actions in the context will also be deleted. def destroy - check_user_set_context - if @context.destroy - render_text "" - else - notify :warning, "Couldn't delete context \"#{@context.name}\"" - redirect_to :action => 'index' + @context.destroy + respond_to do |format| + format.js + format.xml { render :text => "Deleted context #{@context.name}" } end end diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb index 4d4bbd80..43c3ef60 100644 --- a/tracks/app/controllers/projects_controller.rb +++ b/tracks/app/controllers/projects_controller.rb @@ -2,6 +2,7 @@ class ProjectsController < ApplicationController helper :application, :todos, :notes before_filter :init, :except => [:create, :destroy, :order] + before_filter :check_user_set_project, :only => [:update, :destroy, :show] skip_before_filter :login_required, :only => [:index] prepend_before_filter :login_or_feed_token_required, :only => [:index] session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) } @@ -30,7 +31,6 @@ class ProjectsController < ApplicationController end def show - check_user_set_project @page_title = "TRACKS::Project: #{@project.name}" @not_done = @project.not_done_todos(:include_project_hidden_todos => true) @deferred = @project.deferred_todos @@ -73,7 +73,6 @@ class ProjectsController < ApplicationController # Edit the details of the project # def update - check_user_set_project params['project'] ||= {} if params['project']['state'] @project.transition_to(params['project']['state']) @@ -104,18 +103,14 @@ class ProjectsController < ApplicationController end end - # Delete a project - # def destroy - check_user_set_project - if @project.destroy - render :text => '' - else - notify :warning, "Couldn't delete project \"#{@project.name}\"" - redirect_to :action => 'index' + @project.destroy + respond_to do |format| + format.js + format.xml { render :text => "Deleted project #{@project.name}" } end end - + # Methods for changing the sort order of the projects in the list # def order diff --git a/tracks/app/views/contexts/_context_listing.rhtml b/tracks/app/views/contexts/_context_listing.rhtml index 41dd4d4b..099d034c 100644 --- a/tracks/app/views/contexts/_context_listing.rhtml +++ b/tracks/app/views/contexts/_context_listing.rhtml @@ -15,12 +15,10 @@ VISIBLE <% end %> <%= image_tag( "blank.png", :title => "Delete context", :class=>"delete_item") %> - <%= apply_behavior "a.delete_context_button:click", :prevent_default => true do |page| + <%= apply_behavior "a.delete_context_button:click", { :prevent_default => true, :external => true} do |page| page << "if (confirm('Are you sure that you want to ' + this.title + '?')) {" - page << " new Ajax.Updater(this.up('.list')," - page << " this.href, {asynchronous:true," - page << " evalScripts:true, method:'delete'," - page << " onLoading:function(request){ Effect.Fade(this.up('.list'));}}); };" + page << " new Ajax.Request(this.href, {asynchronous:true," + page << " evalScripts:true, method:'delete'}); };" end -%> <%= image_tag( "blank.png", :title => "Edit context", :class=>"edit_item") %> <%= apply_behavior 'a.edit_context_button:click', :prevent_default => true do |page, element| diff --git a/tracks/app/views/contexts/destroy.rjs b/tracks/app/views/contexts/destroy.rjs new file mode 100644 index 00000000..fddfde29 --- /dev/null +++ b/tracks/app/views/contexts/destroy.rjs @@ -0,0 +1,5 @@ +page.visual_effect :fade, dom_id(@context, "container"), :duration => 0.5 +page.delay(0.5) do + page[dom_id(@context, "container")].remove +end +page.notify :notice, "Deleted context '#{@context.name}'", 5.0 diff --git a/tracks/app/views/projects/_project_listing.rhtml b/tracks/app/views/projects/_project_listing.rhtml index 74055619..bacb3f0b 100644 --- a/tracks/app/views/projects/_project_listing.rhtml +++ b/tracks/app/views/projects/_project_listing.rhtml @@ -1,6 +1,6 @@ <% project = project_listing %>