From 8349e760b3163a987d22ac30f81248ea26186714 Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 27 Nov 2005 17:56:34 +0000 Subject: [PATCH] First stage of cleaning up the messages in project/show which remind you if there are no uncompleted or completed actions, or notes in the current project. The show method checks whether @not_done, @done or @notes is empty, and if it is sets a message which is displayed in the partial. I've added Scriptaculous calls to the Ajax for adding a new action, or completing a previously not done action removes the appropriate message (as these activities must logically make @not_done and @done non-empty. Similar thing added for project notes. The next step will be to handle those cases where the last action is completed or deleted, or an unchecked done item refills the not_done actions, which is trickier to pick up. Then I'll repeat for context and todo views. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@164 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/context_controller.rb | 2 +- tracks/app/controllers/project_controller.rb | 20 +++++++- tracks/app/controllers/todo_controller.rb | 2 +- tracks/app/views/layouts/standard.rhtml | 3 +- tracks/app/views/project/_empty.rhtml | 1 - tracks/app/views/project/_show_items.rhtml | 6 ++- tracks/app/views/project/show.rhtml | 47 ++++++++----------- .../app/views/shared/add_new_item_form.rhtml | 5 +- tracks/app/views/todo/_item.rhtml | 1 + tracks/public/stylesheets/standard.css | 15 ++++++ 10 files changed, 64 insertions(+), 38 deletions(-) delete mode 100644 tracks/app/views/project/_empty.rhtml diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index b36dcf18..93c85113 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -65,7 +65,7 @@ class ContextController < ApplicationController item = check_user_return_item item.toggle!('done') - item.completed = Time.now () # For some reason, the before_save in todo.rb stopped working + item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working if item.save render :partial => 'context/show_items', :object => item end diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index 8faef22e..e7cc7ce6 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -28,6 +28,24 @@ class ProjectController < ApplicationController init_todos @notes = @project.notes @page_title = "TRACKS::Project: #{@project.name}" + + if @not_done.empty? + @msg_nd = "Currently there are no uncompleted actions in this project" + else + @msg_nd = nil + end + + if @done.empty? + @msg_d = "Currently there are no completed actions in this project" + else + @msg_d = nil + end + + if @notes.empty? + @msg_n = "Currently there are no notes attached to this project" + else + @msg_n = nil + end end def new_project @@ -64,7 +82,7 @@ class ProjectController < ApplicationController item = check_user_return_item item.toggle!('done') - item.completed = Time.now () # For some reason, the before_save in todo.rb stopped working + item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working if item.save render :partial => 'project/show_items', :object => item end diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 804cf4b4..591233f2 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -119,7 +119,7 @@ class TodoController < ApplicationController item = check_user_return_item item.toggle!('done') - item.completed = Time.now () # For some reason, the before_save in todo.rb stopped working + item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working if item.save render :partial => 'item', :object => item end diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 33aea985..3f103ec3 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -5,8 +5,7 @@ <%= stylesheet_link_tag "standard" %> <%= stylesheet_link_tag "print", :media => "print" %> <%= javascript_include_tag "toggle_notes" %> - <%= javascript_include_tag "prototype" %> - <%= javascript_include_tag "scriptaculous" %> + <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag 'calendar-system.css' %> <%= javascript_include_tag 'calendar', 'calendar-en', 'calendar-setup' %> <%= javascript_include_tag "accesskey-hints" %> diff --git a/tracks/app/views/project/_empty.rhtml b/tracks/app/views/project/_empty.rhtml deleted file mode 100644 index f92ff187..00000000 --- a/tracks/app/views/project/_empty.rhtml +++ /dev/null @@ -1 +0,0 @@ -

<%= message %>

\ No newline at end of file diff --git a/tracks/app/views/project/_show_items.rhtml b/tracks/app/views/project/_show_items.rhtml index 211c5470..8ace1e32 100644 --- a/tracks/app/views/project/_show_items.rhtml +++ b/tracks/app/views/project/_show_items.rhtml @@ -5,7 +5,8 @@ :html => { :id=> "checkbox-notdone-#{item.id}", :class => "inline-form" }, :update => "completed", :position => "top", - :loading => "Form.disable('checkbox-notdone-#{item.id}');", + :loading => "Form.disable('checkbox-notdone-#{item.id}'); + Element.hide('message-done');", :complete => visual_effect(:fade, "item-#{item.id}-container") ) %> @@ -61,7 +62,8 @@ :html => { :id=> "checkbox-done-#{item.id}", :class => "inline-form" }, :update => "next_actions", :position => "bottom", - :loading => "Form.disable('checkbox-done-#{item.id}');", + :loading => "Form.disable('checkbox-done-#{item.id}'); + Element.hide('message-notdone');", :complete => visual_effect(:fade, "done-item-#{item.id}-container") ) %> diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index 0e1cf124..d8d760d5 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -6,22 +6,17 @@
<%= sanitize(@project.description) %>
<% end -%> + <% if @msg_nd -%> +
+

<%= @msg_nd %>

+
+ <% end -%> +
<% if @project.done? -%>

Project has been marked as completed

<% end -%> - <% if !@project.done? and @not_done.empty? -%> -
- <%= render :partial => "empty", - :locals => { :message => "There are currently no uncompleted actions in this project"} %> -
- <% else -%> - - <% end -%> - <%= render :partial => "show_items", :collection => @not_done %> + <%= render :partial => "show_items", :collection => @not_done %>
@@ -29,18 +24,12 @@

Completed actions in this project

- <% if @done.empty? %> -
- <%= render :partial => "empty", - :locals => {:message => "There are currently no completed next actions in this project"} %> -
- <% else -%> - + <% if @msg_d -%> +
+

<%= @msg_d %>

+
<% end -%> - <%= render :partial => "show_items", :collection => @done %> + <%= render :partial => "show_items", :collection => @done %>
@@ -48,11 +37,12 @@

Notes

- <% if @notes.empty? -%> -

There are no notes yet for this project.

- <% else -%> + <% if @msg_n -%> +
+

<%= @msg_n %>

+
+ <% end -%> <%= render :partial => "note/notes_summary", :collection => @notes %> - <% end -%>
@@ -69,7 +59,8 @@ <%= form_remote_tag :url => { :controller => "note", :action => "add" }, :update => "notes", :position => "bottom", - :complete => "new Effect.Highlight('notes');", + :complete => "new Effect.Highlight('notes'); + Element.hide('message-notes');", :html => {:id=>'form-new-note', :class => 'inline-form'} %> <%= hidden_field( "new_note", "project_id", "value" => "#{@project.id}" ) %> <%= text_area( "new_note", "body", "cols" => 50, "rows" => 3, "tabindex" => 1 ) %> diff --git a/tracks/app/views/shared/add_new_item_form.rhtml b/tracks/app/views/shared/add_new_item_form.rhtml index 0cf62e84..e5b94fdc 100644 --- a/tracks/app/views/shared/add_new_item_form.rhtml +++ b/tracks/app/views/shared/add_new_item_form.rhtml @@ -22,8 +22,9 @@ <%= form_remote_tag( :url => { :controller => "todo", :action => "add_item" }, :update => update_div, - :position=> "bottom", - :complete => "Form.focusFirstElement('todo-form-new-action');", + :position => "bottom", + :complete => "Form.focusFirstElement('todo-form-new-action'); + Element.remove('message-notdone');", :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) %>
diff --git a/tracks/app/views/todo/_item.rhtml b/tracks/app/views/todo/_item.rhtml index cd5b96f3..a53639d7 100644 --- a/tracks/app/views/todo/_item.rhtml +++ b/tracks/app/views/todo/_item.rhtml @@ -1,4 +1,5 @@ <% if !item.done? %> +
<%= form_remote_tag_todo_notdone( item ) %>
diff --git a/tracks/public/stylesheets/standard.css b/tracks/public/stylesheets/standard.css index 5e915c00..df26f9dd 100644 --- a/tracks/public/stylesheets/standard.css +++ b/tracks/public/stylesheets/standard.css @@ -499,4 +499,19 @@ input, select { padding: 1px; font-size: 10px; cursor: move; +} + + +div.message { + margin: 5px 0px; + background: #FAF4B5; + padding: 2px; +} + +.message p { + margin: 0px; + padding: 0px; + text-align: center; + font-size: 1em; + color: #666; } \ No newline at end of file