Clean up todo controller by extracting deferred todo functionality into a new deferred controller. Thanks to Trotter Cashion for his presentation on CRUD at the nyc.rb group that was the inspiration for this cleanup. See http://lifecoding.com/blog/?p=31 for slides.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@293 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2006-07-28 04:09:02 +00:00
parent 0a00eaffb9
commit afaf2235fa
23 changed files with 330 additions and 175 deletions

View file

@ -0,0 +1,123 @@
class DeferredController < ApplicationController
model :user
model :project
model :context
helper :todo
prepend_before_filter :login_required
layout "standard"
def index
init_projects_and_contexts
@page_title = "TRACKS::Tickler"
@tickles = @user.todos.find(:all, :conditions => ['type = ?', "Deferred"], :order => "show_from ASC")
@count = @tickles.size
end
def create
@item = Deferred.create(params["todo"])
@item.user_id = @user.id
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@saved = @item.save
if @saved
@up_count = @user.todos.count(['type = ?', "Deferred"])
end
respond_to do |wants|
wants.html { redirect_to :action => "index" }
wants.js
wants.xml { render :xml => @item.to_xml( :root => 'todo', :except => :user_id ) }
end
end
def edit
init_projects_and_contexts
@item = check_user_return_item
render :layout => false
end
def update
@item = check_user_return_item
@original_item_context_id = @item.context_id
@item.attributes = params["item"]
if @item.due?
@item.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@saved = @item.save
end
def destroy
@item = check_user_return_item
context_id = @item.context_id
@saved = @item.destroy
respond_to do |wants|
wants.html do
flash["notice"] = 'Successfully deleted next action' if @saved
redirect_to :action => "index"
end
wants.js do
@down_count = @user.todos.count(['type = ?', "Deferred"]) if @saved
render
end
wants.xml { render :xml => @item.to_xml( :root => 'todo', :except => :user_id ) }
end
rescue
respond_to do |wants|
wants.html do
flash["warning"] = 'An error occurred on the server.'
redirect_to :action => "index"
end
wants.js { render :action => 'error' }
wants.xml { render :text => "500 Server Error: There was an error deleting the action.", :status => 500 }
end
end
# Check for any due tickler items, change them to type Immediate.
# Called by periodically_call_remote
def check_tickler
now = Date.today()
@due_tickles = @user.todos.find(:all, :conditions => ['type = ? AND (show_from < ? OR show_from = ?)', "Deferred", now, now ], :order => "show_from ASC")
# Change the due tickles to type "Immediate"
@due_tickles.each do |t|
t[:type] = "Immediate"
t.show_from = nil
t.save_with_validation(false)
end
end
protected
def init_projects_and_contexts
@projects = @user.projects
@contexts = @user.contexts
end
private
def check_user_return_item
item = Todo.find( params['id'] )
if @user == item.user
return item
else
flash["warning"] = "Item and session user mis-match: #{item.user.name} and #{@user.name}!"
render_text ""
end
end
end

View file

@ -15,7 +15,7 @@ class LoginController < ApplicationController
msg = (should_expire_sessions?) ? "will expire after 1 hour of inactivity." : "will not expire."
flash['notice'] = "Login successful: session #{msg}"
cookies[:tracks_login] = { :value => @user.login, :expires => Time.now + 1.year }
redirect_back_or_default :controller => "todo", :action => "list"
redirect_back_or_default :controller => "todo", :action => "index"
else
@login = params['user_login']
flash['warning'] = "Login unsuccessful"
@ -54,7 +54,7 @@ class LoginController < ApplicationController
@user.preferences = { "date_format" => "%d/%m/%Y", "week_starts" => "1", "no_completed" => "5", "staleness_starts" => "7", "due_style" => "1", "admin_email" => "butshesagirl@rousette.org.uk"}
@user.save
flash['notice'] = "Signup successful for user #{@user.login}."
redirect_back_or_default :controller => "todo", :action => "list"
redirect_back_or_default :controller => "todo", :action => "index"
end
end
@ -64,7 +64,7 @@ class LoginController < ApplicationController
# TODO: Maybe it would be better to mark deleted. That way user deletes can be reversed.
@user.destroy
end
redirect_back_or_default :controller => "todo", :action => "list"
redirect_back_or_default :controller => "todo", :action => "index"
end
def logout

View file

@ -89,10 +89,10 @@ class ProjectController < ApplicationController
# fallback for standard requests
if @saved
flash["notice"] = 'Added new next action.'
redirect_to :controller => 'todo', :action => 'list'
redirect_to :controller => 'todo', :action => 'index'
else
flash["warning"] = 'The next action was not added. Please try again.'
redirect_to :controller => 'todo', :action => 'list'
redirect_to :controller => 'todo', :action => 'index'
end
rescue
@ -100,7 +100,7 @@ class ProjectController < ApplicationController
render :action => 'error'
else
flash["warning"] = 'An error occurred on the server.'
redirect_to :controller => 'todo', :action => 'list'
redirect_to :controller => 'todo', :action => 'index'
end
end
@ -121,9 +121,9 @@ class ProjectController < ApplicationController
# fallback for standard requests
if @saved
flash["notice"] = 'Successfully deleted next action'
redirect_to :controller => 'todo', :action => 'list'
redirect_to :controller => 'todo', :action => 'index'
else
render :controller => 'todo', :action => 'list'
render :controller => 'todo', :action => 'index'
end
rescue
@ -131,7 +131,7 @@ class ProjectController < ApplicationController
render :action => 'error'
else
flash["warning"] = 'An error occurred on the server.'
render :controller => 'todo', :action => 'list'
render :controller => 'todo', :action => 'index'
end
end

View file

@ -9,16 +9,10 @@ class TodoController < ApplicationController
prepend_before_filter :login_required
layout "standard"
def index
list
render_action "list"
end
# Main method for listing tasks
# Set page title, and fill variables with contexts and done and not-done tasks
# Number of completed actions to show is determined by a setting in settings.yml
#
def list
def index
self.init
@on_page = "home"
@page_title = "TRACKS::List tasks"
@ -56,18 +50,35 @@ class TodoController < ApplicationController
@item.attributes = params["todo"]
@on_page = "home"
perform_add_item('list')
end
# Adding deferred actions from form on todo/tickler
#
def add_deferred_item
self.init
@item = Deferred.create(params["todo"])
@item.user_id = @user.id
@on_page = "tickler"
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
perform_add_item('tickler')
@saved = @item.save
if @saved
init_todos
@up_count = @todos.reject { |x| x.done? or x.context.hide? }.size.to_s
end
respond_to do |wants|
wants.html { redirect_to :action => "index" }
wants.js
wants.xml { render :xml => @item.to_xml( :root => 'todo', :except => :user_id ) }
end
# if you're seeing the message 'An error occurred on the server.' and you want to debug, comment out the rescue section and check the Ajax response for an exception message
rescue
respond_to do |wants|
wants.html do
flash["warning"] = 'An error occurred on the server.'
render :action => "index"
end
wants.js { render :action => 'error' }
wants.xml { render :text => 'An error occurred on the server.' + $! }
end
end
def edit_action
@ -105,7 +116,7 @@ class TodoController < ApplicationController
else
flash['notice'] = "The action <strong>'#{@item.description}'</strong> was NOT marked as <strong>#{@item.done? ? 'complete' : 'incomplete' } due to an error on the server.</strong>"
end
redirect_to :action => "list"
redirect_to :action => "index"
end
# Edit the details of an action
@ -128,21 +139,6 @@ class TodoController < ApplicationController
@saved = @item.save
end
def deferred_update_action
#self.init
@tickle = check_user_return_item
@original_item_context_id = @tickle.context_id
@tickle.attributes = params["item"]
if @tickle.due?
@tickle.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
else
@tickle.due = ""
end
@saved = @tickle.save
end
def update_context
self.init
@item = check_user_return_item
@ -197,9 +193,9 @@ class TodoController < ApplicationController
# fallback for standard requests
if @saved
flash["notice"] = 'Successfully deleted next action'
redirect_to :action => 'list'
redirect_to :action => 'index'
else
render :action => 'list'
render :action => 'index'
end
rescue
@ -207,7 +203,7 @@ class TodoController < ApplicationController
render :action => 'error'
else
flash["warning"] = 'An error occurred on the server.'
render :action => 'list'
render :action => 'index'
end
end
@ -239,30 +235,6 @@ class TodoController < ApplicationController
@page_title = "TRACKS::Feeds"
end
def tickler
self.init
@page_title = "TRACKS::Tickler"
@tickles = @user.todos.find(:all, :conditions => ['type = ?', "Deferred"], :order => "show_from ASC")
@count = @tickles.size
@on_page = "tickler"
end
# Called by periodically_call_remote
# Check for any due tickler items, change them to type Immediate and show
# on the page
#
def check_tickler
self.init
now = Date.today()
@due_tickles = @user.todos.find(:all, :conditions => ['type = ? AND (show_from < ? OR show_from = ?)', "Deferred", now, now ], :order => "show_from ASC")
# Change the due tickles to type "Immediate"
@due_tickles.each do |t|
t[:type] = "Immediate"
t.show_from = nil
t.save_with_validation(false)
end
end
protected
def check_user_return_item
@ -284,37 +256,6 @@ class TodoController < ApplicationController
def init_todos
@todos = Todo.find(:all, :conditions => ['user_id = ? and type = ?', @user.id, "Immediate"])
@done = Todo.find(:all, :conditions => ['user_id = ? and done = ?', @user.id, true], :order => 'completed DESC')
end
def perform_add_item(redirect_action)
if @item.due?
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@saved = @item.save
if @saved
init_todos
@up_count = @todos.reject { |x| x.done? or x.context.hide? }.size.to_s
end
respond_to do |wants|
wants.html { redirect_to :action => redirect_action }
wants.js
wants.xml { render :xml => @item.to_xml( :root => 'todo', :except => :user_id ) }
end
# if you're seeing the message 'An error occurred on the server.' and you want to debug, comment out the rescue section and check the Ajax response for an exception message
rescue
respond_to do |wants|
wants.html { render :action => redirect_action } # TODO: would prefer something like: flash["warning"] = 'An error occurred on the server.' render :action => 'list'
wants.js { render :action => 'error' }
wants.xml { render :text => 'An error occurred on the server.' + $! }
end
end
end
end

View file

@ -8,24 +8,26 @@ module TodoHelper
end
def form_remote_tag_edit_todo( item, type )
(type == "deferred") ? act = 'deferred_update_action' : act = 'update_action'
form_remote_tag( :url => { :controller => 'todo', :action => act, :id => item.id },
(type == "deferred") ? act = 'update' : act = 'update_action'
(type == "deferred") ? controller_name = 'deferred' : controller_name = 'todo'
form_remote_tag( :url => { :controller => controller_name, :action => act, :id => item.id },
:html => { :id => "form-action-#{item.id}", :class => "inline-form" }
)
end
def link_to_remote_todo( item, handled_by, type)
(type == "deferred") ? destroy_act = 'destroy' : destroy_act = 'destroy_action'
str = link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
{:url => { :controller => handled_by, :action => "destroy_action", :id => item.id },
{:url => { :controller => handled_by, :action => destroy_act, :id => item.id },
:confirm => "Are you sure that you want to delete the action, \'#{item.description}\'?"},
{:class => "icon"}) + "\n"
if !item.done?
(type == "deferred") ? edit_act = 'edit' : edit_act = 'edit_action'
str << link_to_remote( image_tag("blank", :title =>"Edit action", :class=>"edit_item", :id=>"action-#{item.id}-edit-icon"),
{
:update => "form-action-#{item.id}",
:loading => visual_effect(:pulsate, "action-#{item.id}-edit-icon"),
:url => { :controller => "todo", :action => "edit_action", :id => item.id },
:url => { :controller => handled_by, :action => edit_act, :id => item.id },
:success => "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form', { duration: .2 }); Form.focusFirstElement('form-action-#{item.id}')"
},
{

View file

@ -0,0 +1,25 @@
<div id="item-<%= item.id %>-container" class="item-container">
<div id="item-<%= item.id %>">
<%= link_to_remote_todo( item, controller.controller_name, "deferred" ) %>
<div class="description">
<%= show_date( item.show_from ) -%>
<%= sanitize(item.description) %>
<% if item.due -%>
(action due on <%= item.due.to_s %>)
<% end -%>
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %>
<% if item.project_id -%>
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>
<% end -%>
<% if item.notes? -%>
<%= toggle_show_notes( item ) %>
<% end -%>
</div>
</div><!-- [end:item-<%= item.id %>] -->
<div id="action-<%= item.id %>-edit-form" class="edit-form" style="display:none;">
<%= form_remote_tag_edit_todo( item, "deferred" ) -%>
<% #note: edit form will load here remotely -%>
<%= end_form_tag -%>
</div><!-- [end:action-<%= item.id %>-edit-form] -->
</div><!-- [end:item-<%= item.id %>-container] -->

View file

@ -6,7 +6,7 @@
<div class="message"><p>Currently there are no deferred actions</p></div>
</div>
<%= render :partial => "tickle", :collection => @tickles %>
<%= render :partial => "item", :collection => @tickles %>
</div><!-- [end:items] -->
</div><!-- [end:tickler] -->

View file

@ -4,7 +4,7 @@ if @saved
page.visual_effect :appear, 'status', :duration => 0.5
page.replace_html "badge_count", @up_count
page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')"
page.insert_html :bottom, "tickler", :partial => 'todo/tickle', :object => @item
page.insert_html :bottom, "tickler", :partial => 'deferred/item', :object => @item
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
page["tickler-empty-nd"].hide
else

View file

@ -0,0 +1,9 @@
if @saved
page["item-#{@item.id}-container"].remove
page['badge_count'].replace_html @down_count
if @down_count == 0
page.visual_effect :appear, "tickler-empty-nd", :duration => 0.4
end
else
page["status"].replace_html content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
end

View file

@ -0,0 +1,64 @@
<%= error_messages_for("item") %>
<%= hidden_field( "item", "id" ) %>
<table>
<tr>
<td class="label"><label for="item_description">Next action</label></td>
<td><%= text_field( "item", "description", "tabindex" => 1) %></td>
</tr>
<tr>
<td class="label"><label for="item_notes">Notes</label></td>
<td><%= text_area( "item", "notes", "cols" => 20, "rows" => 5, "tabindex" => 2) %></td>
</tr>
<tr>
<td class="label"><label for="item_context_id">Context</label></td>
<td><select name="item[context_id]" id="item_context_id" tabindex="3">
<% for @place in @contexts %>
<% if @item %>
<% if @place.id == @item.context_id %>
<option value="<%= @place.id %>" selected="selected"><%= @place.name %></option>
<% else %>
<option value="<%= @place.id %>"><%= @place.name %></option>
<% end %>
<% else %>
<option value="<%= @place.id %>"><%= @place.name %></option>
<% end %>
<% end %>
</select></td>
</tr>
<tr>
<td class="label"><label for="item_project_id">Project</label></td>
<td>
<select name="item[project_id]" id="item_project_id" tabindex="4">
<% if !@item.project_id? %>
<option selected="selected"></option>
<%= options_from_collection_for_select(@projects, "id", "name") %>
<% else %>
<option></option>
<%= options_from_collection_for_select(@projects, "id", "name", @item.project_id) %>
<% end %>
</select>
</td>
</tr>
<tr>
<td class="label"><label for="item_due">Due</td>
<td><input name="item[due]" id="due_<%= @item.id %>" type="text" value="<%= format_date(@item.due) %>" tabindex="5" size="10" onFocus="Calendar.setup" /></td>
</tr>
<% if @item.class == Deferred -%>
<tr>
<td class="label"><label for="item_show_from">Show from</td>
<td><input name="item[show_from]" id="show_from_<%= @item.id %>" type="text" value="<%= format_date(@item.show_from) %>" tabindex="5" size="10" onFocus="Calendar.setup" /></td>
</tr>
<% end -%>
<% if controller.controller_name == "project" || @item.class == 'Deferred' -%>
<input type="hidden" name="on_project_page" value="true" />
<% end -%>
<tr>
<td><input type="submit" value="Update" tabindex="6" />
<a href="javascript:void(0);" onclick="Element.toggle('item-<%= @item.id %>','action-<%= @item.id %>-edit-form');Form.reset('form-action-<%= @item.id %>');">Cancel</a></td>
</tr>
</table>
<%= calendar_setup( "due_#{@item.id}" ) %>
<% if @item.class == Deferred -%>
<%= calendar_setup( "show_from_#{@item.id}" ) %>
<% end -%>

View file

@ -0,0 +1 @@
page["status"].replace_html "An error occurred on the server."

View file

@ -0,0 +1,16 @@
<div id="display_box">
<% for name in ["notice", "warning", "message"] %>
<% if flash[name] %>
<%= "<div id=\"#{name}\">#{flash[name]}</div>" %>
<% end %>
<% end %>
<%= render :partial => "items" %>
</div><!-- End of display_box -->
<div id="input_box">
<%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %>
<%= render "shared/sidebar" %>
</div><!-- End of input box -->

View file

@ -0,0 +1,14 @@
page.hide "info"
if @saved
if @item.context_id == @original_item_context_id
page.replace "item-#{@item.id}-container", :partial => 'deferred/item'
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
else
page["item-#{@item.id}-container"].remove
page.insert_html :bottom, "c#{@item.context_id}items", :partial => 'deferred/item'
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
end
else
page.replace_html "info", content_tag("div", content_tag("div", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved", "id" => "warning", "class" => "warning") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }))
page.visual_effect :appear, 'info', :duration => 0.5
end

View file

@ -43,10 +43,10 @@
<div id="navcontainer">
<ul id="navlist">
<li><%= navigation_link("Home", {:controller => "todo", :action => "list"}, {:accesskey => "t", :title => "Home"} ) %></li>
<li><%= navigation_link("Home", {:controller => "todo", :action => "index"}, {:accesskey => "t", :title => "Home"} ) %></li>
<li><%= navigation_link( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %></li>
<li><%= navigation_link( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %></li>
<li><%= navigation_link( "Tickler", {:controller => "todo", :action => "tickler"}, :title => "Ticker" ) %></li>
<li><%= navigation_link( "Tickler", {:controller => "deferred", :action => "index"}, :title => "Ticker" ) %></li>
<li><%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %></li>
<li><%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "o", :title => "Show all notes"} ) %></li>
<li><%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %></li>
@ -61,7 +61,7 @@
<%= periodically_call_remote( :url => {:controller => "login", :action => "check_expiry"},
:frequency => (5*60)) %>
<% end -%>
<%= periodically_call_remote( :url => {:controller => "todo", :action => "check_tickler"},
<%= periodically_call_remote( :url => {:controller => "deferred", :action => "check_tickler"},
:frequency => (10*60)) %>
<%= @content_for_layout %>
</div>

View file

@ -8,15 +8,15 @@
add_string = "Add a next action in this project &#187;"
@selected_context = @contexts[0].id
@selected_project = @project.id
when "deferred"
add_string = "Add a deferred action &#187;"
@selected_context = @contexts[0].id
@selected_project = nil
else
add_string = "Add a next action &#187;"
@selected_context = @contexts[0].id
@selected_project = nil
end
if @on_page == "tickler"
add_string = "Add a deferred action &#187;"
end
end
%>
<% hide_link ||= false %>
@ -31,15 +31,15 @@
<div id="status">
</div>
<!--[form:todo]-->
<% if @on_page == "tickler" -%>
<% if controller.controller_name == "deferred" -%>
<%= form_remote_tag(
:url => { :controller => controller.controller_name, :action => "add_deferred_item" },
:url => { :controller => "deferred", :action => "create" },
:html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) %>
<% end -%>
<% else -%>
<%= form_remote_tag(
:url => { :controller => controller.controller_name, :action => "add_item" },
:html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) %>
<% end -%>
<label for="todo_description">Description</label><br />
<%= text_field( "todo", "description", "size" => 25, "tabindex" => 1) %><br />
@ -59,7 +59,7 @@
<label for="todo_due">Due</label><br />
<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %>
<% if @on_page == "tickler" -%>
<% if controller.controller_name == "deferred" -%>
<br /> <label for="todo_show_from">Show from</label><br />
<%= text_field("todo", "show_from", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %><br />
<% end -%>
@ -68,7 +68,7 @@
<input type="submit" value="Add item" tabindex="6">
<%= end_form_tag %><!--[eoform:todo]-->
<%= calendar_setup( "todo_due" ) %>
<% if @on_page == "tickler" -%>
<% if controller.controller_name == "deferred" -%>
<%= calendar_setup( "todo_show_from" ) %>
<% end -%>
</div><!-- [end:todo-new-action] -->

View file

@ -1,21 +1,17 @@
<%
@selected_context = @contexts[0].id
@selected_project = nil
case controller.controller_name
when "context"
add_string = "Add a next action in this context &#187;"
@selected_context = @context.id
@selected_project = nil
when "project"
add_string = "Add a next action in this project &#187;"
@selected_context = @contexts[0].id
@selected_project = @project.id
else
when "deferred"
add_string = "Add a next action &#187;"
@selected_context = @contexts[0].id
@selected_project = nil
end
if @on_page == "tickler"
add_string = "Add a deferred action &#187;"
else
add_string = "Add a deferred action &#187;"
end
%>
<% hide_link ||= false %>
@ -57,7 +53,7 @@
<td><%= text_field("todo", "due", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %></td>
</tr>
<% if @on_page == "tickler" -%>
<% if controller.controller_name == "tickler" -%>
<tr>
<td><label for="todo_show_from">Show from</label></td>
<td><%= date_select( "todo", "show_from", :start_year => Date.today.year, :order => [:year, :month, :day] ) %></td>

View file

@ -1,26 +0,0 @@
<div id="item-<%= tickle.id %>-container" class="item-container">
<div id="item-<%= tickle.id %>">
<%= link_to_remote_todo( tickle, controller.controller_name, "deferred" ) %>
<div class="description">
<%= show_date( tickle.show_from ) -%>
<%= sanitize(tickle.description) %>
<% if tickle.due -%>
(action due on <%= tickle.due.to_s %>)
<% end -%>
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(tickle.context.name) }, :title => "View context: #{tickle.context.name}" ) %>
<% if tickle.project_id -%>
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(tickle.project.name) }, :title => "View project: #{tickle.project.name}" ) %>
<% end -%>
<% if tickle.notes? -%>
<%= toggle_show_notes( tickle ) %>
<% end -%>
</div>
</div><!-- [end:item-tickle.id] -->
<div id="action-<%= tickle.id %>-edit-form" class="edit-form" style="display:none;">
<%= form_remote_tag_edit_todo( tickle, "deferred" ) -%>
<% #note: edit form will load here remotely -%>
<%= end_form_tag -%>
</div><!-- [end:action-tickle.id-edit-form] -->
</div><!-- [end:item-tickle.id-container] -->

View file

@ -1,14 +0,0 @@
page.hide "info"
if @saved
if @tickle.context_id == @original_item_context_id
page.replace "item-#{@tickle.id}-container", :partial => 'todo/tickle'
page.visual_effect :highlight, "item-#{@tickle.id}-container", :duration => 3
else
page["item-#{@tickle.id}-container"].remove
page.insert_html :bottom, "c#{@tickle.context_id}items", :partial => 'todo/tickle'
page.visual_effect :highlight, "item-#{@tickle.id}-container", :duration => 3
end
else
page.replace_html "info", content_tag("div", content_tag("div", "#{pluralize(@tickle.errors.count, "error")} prohibited this record from being saved", "id" => "warning", "class" => "warning") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @tickle.errors.each_full { |msg| content_tag("li", msg) }))
page.visual_effect :appear, 'info', :duration => 0.5
end

View file

@ -15,7 +15,7 @@ ActionController::Routing::Routes.draw do |map|
#map.connect ':controller/service.wsdl', :action => 'wsdl'
# Index Route
map.connect '', :controller => 'todo', :action => 'list'
map.connect '', :controller => 'todo', :action => 'index'
# Mobile/lite version
map.connect 'mobile', :controller => 'mobile', :action => 'list'
@ -30,6 +30,10 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'done', :controller => 'todo', :action => 'completed'
map.connect 'delete/todo/:id', :controller =>'todo', :action => 'destroy'
# Deferred (Tickler) Routes
map.connect 'tickler', :controller => 'deferred', :action => 'index'
map.connect 'tickler/:action/:id', :controller => 'deferred'
# Context Routes
map.connect 'context/new_context', :controller => 'context', :action => 'new_context'
map.connect 'context/add_item', :controller => 'context', :action => 'add_item'

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 B

View file

@ -20,7 +20,7 @@ div.calendar { position: relative; }
}
.calendar .nav {
background: #778 url(menuarrow.gif) no-repeat 100% 100%;
background: #778 url(../images/menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */