From 6b09ffa0a812d16e893ba7e966decbde4ee8cd0f Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 26 Feb 2006 12:02:11 +0000 Subject: [PATCH] Added a flash warning to todo/list and project/show/[name] pages when contexts are empty to remind users that you need to add a context before adding any next actions. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@194 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/project_controller.rb | 4 ++++ tracks/app/controllers/todo_controller.rb | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index bd08a906..36fd26df 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -30,6 +30,10 @@ class ProjectController < ApplicationController @on_page = "project" @page_title = "TRACKS::Project: #{@project.name}" + if @contexts.empty? + flash['warning'] = 'You must add at least one context before adding next actions.' + end + if @not_done.empty? @msg_nd = "Currently there are no uncompleted actions in this project" else diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index fea42763..07a8cd72 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -27,6 +27,10 @@ class TodoController < ApplicationController @contexts_to_show = @contexts.clone @contexts_to_show = @contexts_to_show.collect {|x| (!x.hide? and !x.find_not_done_todos.empty?) ? x:nil }.compact + + if @contexts.empty? + flash['warning'] = 'You must add at least one context before adding next actions.' + end # Set count badge to number of not-done, not hidden context items @count = @todos.collect { |x| ( !x.done? and !x.context.hide? ) ? x:nil }.compact.size @@ -48,8 +52,9 @@ class TodoController < ApplicationController else @item.due = "" end - + @saved = @item.save + @on_page = "home" if @saved @up_count = @todos.collect { |x| ( !x.done? and !x.context.hide? ) ? x:nil }.compact.size.to_s