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
This commit is contained in:
bsag 2005-11-27 17:56:34 +00:00
parent d7e7e9346d
commit 8349e760b3
10 changed files with 64 additions and 38 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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" %>

View file

@ -1 +0,0 @@
<p><%= message %></p>

View file

@ -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")
) %>

View file

@ -6,22 +6,17 @@
<div class="project_description"><%= sanitize(@project.description) %></div>
<% end -%>
<% if @msg_nd -%>
<div id="message-notdone" class="message" style="display: block;">
<p><%= @msg_nd %></p>
</div>
<% end -%>
<div id="next_actions">
<% if @project.done? -%>
<p class="completed">Project has been marked as completed</p>
<% end -%>
<% if !@project.done? and @not_done.empty? -%>
<div id="empty-nd" style="display:block;">
<%= render :partial => "empty",
:locals => { :message => "There are currently no uncompleted actions in this project"} %>
</div>
<% else -%>
<div id="empty-nd" style="display:none;">
<%= render :partial => "empty",
:locals => { :message => "There are currently no uncompleted actions in this project"} %>
</div>
<% end -%>
<%= render :partial => "show_items", :collection => @not_done %>
<%= render :partial => "show_items", :collection => @not_done %>
</div><!-- [end:next_actions] -->
</div><!-- [end:contexts] -->
@ -29,18 +24,12 @@
<h2>Completed actions in this project</h2>
<div id="completed">
<% if @done.empty? %>
<div id="empty-d">
<%= render :partial => "empty",
:locals => {:message => "There are currently no completed next actions in this project"} %>
</div>
<% else -%>
<div id="empty-nd" style="display:none;">
<%= render :partial => "empty",
:locals => { :message => "There are currently no uncompleted actions in this project"} %>
</div>
<% if @msg_d -%>
<div id="message-done" class="message" style="display: block;">
<p><%= @msg_d %></p>
</div>
<% end -%>
<%= render :partial => "show_items", :collection => @done %>
<%= render :partial => "show_items", :collection => @done %>
</div>
</div><!-- [end:contexts] -->
@ -48,11 +37,12 @@
<div class="contexts">
<div id="notes">
<h2>Notes</h2>
<% if @notes.empty? -%>
<p>There are no notes yet for this project.</p>
<% else -%>
<% if @msg_n -%>
<div id="message-notes" class="message" style="display: block;">
<p><%= @msg_n %></p>
</div>
<% end -%>
<%= render :partial => "note/notes_summary", :collection => @notes %>
<% end -%>
</div>
</div>
<!-- end div.contexts -->
@ -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 ) %>

View file

@ -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' }) %>
<label for="new_item_description">Description</label><br />

View file

@ -1,4 +1,5 @@
<% if !item.done? %>
<div id="item-<%= item.id %>-container">
<%= form_remote_tag_todo_notdone( item ) %>
<div id="item-<%= item.id %>">

View file

@ -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;
}