diff --git a/tracks/app/controllers/deferred_controller.rb b/tracks/app/controllers/deferred_controller.rb
new file mode 100644
index 00000000..b7b20e0a
--- /dev/null
+++ b/tracks/app/controllers/deferred_controller.rb
@@ -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
\ No newline at end of file
diff --git a/tracks/app/controllers/login_controller.rb b/tracks/app/controllers/login_controller.rb
index 73ad2100..2d49e1b7 100644
--- a/tracks/app/controllers/login_controller.rb
+++ b/tracks/app/controllers/login_controller.rb
@@ -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
diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb
index faf7882a..1b65b1d3 100644
--- a/tracks/app/controllers/project_controller.rb
+++ b/tracks/app/controllers/project_controller.rb
@@ -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
diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb
index 1617c0ab..a9be5427 100644
--- a/tracks/app/controllers/todo_controller.rb
+++ b/tracks/app/controllers/todo_controller.rb
@@ -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 '#{@item.description}' was NOT marked as #{@item.done? ? 'complete' : 'incomplete' } due to an error on the server. "
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
diff --git a/tracks/app/helpers/todo_helper.rb b/tracks/app/helpers/todo_helper.rb
index 599d8c11..ed8316a2 100644
--- a/tracks/app/helpers/todo_helper.rb
+++ b/tracks/app/helpers/todo_helper.rb
@@ -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}')"
},
{
diff --git a/tracks/app/views/deferred/_item.rhtml b/tracks/app/views/deferred/_item.rhtml
new file mode 100644
index 00000000..2654829c
--- /dev/null
+++ b/tracks/app/views/deferred/_item.rhtml
@@ -0,0 +1,25 @@
+
+
+ <%= link_to_remote_todo( item, controller.controller_name, "deferred" ) %>
+
+ <%= 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 -%>
+
+
+
+ <%= form_remote_tag_edit_todo( item, "deferred" ) -%>
+ <% #note: edit form will load here remotely -%>
+ <%= end_form_tag -%>
+
+
\ No newline at end of file
diff --git a/tracks/app/views/todo/_tickler_items.rhtml b/tracks/app/views/deferred/_items.rhtml
similarity index 84%
rename from tracks/app/views/todo/_tickler_items.rhtml
rename to tracks/app/views/deferred/_items.rhtml
index cb65f9a7..dafcaa82 100644
--- a/tracks/app/views/todo/_tickler_items.rhtml
+++ b/tracks/app/views/deferred/_items.rhtml
@@ -6,7 +6,7 @@
Currently there are no deferred actions
- <%= render :partial => "tickle", :collection => @tickles %>
+ <%= render :partial => "item", :collection => @tickles %>
\ No newline at end of file
diff --git a/tracks/app/views/todo/check_tickler.rjs b/tracks/app/views/deferred/check_tickler.rjs
similarity index 100%
rename from tracks/app/views/todo/check_tickler.rjs
rename to tracks/app/views/deferred/check_tickler.rjs
diff --git a/tracks/app/views/todo/add_deferred_item.rjs b/tracks/app/views/deferred/create.rjs
similarity index 91%
rename from tracks/app/views/todo/add_deferred_item.rjs
rename to tracks/app/views/deferred/create.rjs
index ce393e74..9fe60c5c 100644
--- a/tracks/app/views/todo/add_deferred_item.rjs
+++ b/tracks/app/views/deferred/create.rjs
@@ -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
diff --git a/tracks/app/views/deferred/destroy.rjs b/tracks/app/views/deferred/destroy.rjs
new file mode 100644
index 00000000..368d48e8
--- /dev/null
+++ b/tracks/app/views/deferred/destroy.rjs
@@ -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
\ No newline at end of file
diff --git a/tracks/app/views/deferred/edit.rhtml b/tracks/app/views/deferred/edit.rhtml
new file mode 100644
index 00000000..3eceda08
--- /dev/null
+++ b/tracks/app/views/deferred/edit.rhtml
@@ -0,0 +1,64 @@
+<%= error_messages_for("item") %>
+
+<%= hidden_field( "item", "id" ) %>
+
+
+ Next action
+ <%= text_field( "item", "description", "tabindex" => 1) %>
+
+
+ Notes
+ <%= text_area( "item", "notes", "cols" => 20, "rows" => 5, "tabindex" => 2) %>
+
+
+ Context
+
+ <% for @place in @contexts %>
+ <% if @item %>
+ <% if @place.id == @item.context_id %>
+ <%= @place.name %>
+ <% else %>
+ <%= @place.name %>
+ <% end %>
+ <% else %>
+ <%= @place.name %>
+ <% end %>
+ <% end %>
+
+
+
+ Project
+
+
+ <% if !@item.project_id? %>
+
+ <%= options_from_collection_for_select(@projects, "id", "name") %>
+ <% else %>
+
+ <%= options_from_collection_for_select(@projects, "id", "name", @item.project_id) %>
+ <% end %>
+
+
+
+
+ Due
+
+
+ <% if @item.class == Deferred -%>
+
+ Show from
+
+
+ <% end -%>
+ <% if controller.controller_name == "project" || @item.class == 'Deferred' -%>
+
+ <% end -%>
+
+
+ Cancel
+
+
+<%= calendar_setup( "due_#{@item.id}" ) %>
+<% if @item.class == Deferred -%>
+ <%= calendar_setup( "show_from_#{@item.id}" ) %>
+<% end -%>
\ No newline at end of file
diff --git a/tracks/app/views/deferred/error.rjs b/tracks/app/views/deferred/error.rjs
new file mode 100644
index 00000000..9a5a0dcc
--- /dev/null
+++ b/tracks/app/views/deferred/error.rjs
@@ -0,0 +1 @@
+page["status"].replace_html "An error occurred on the server."
\ No newline at end of file
diff --git a/tracks/app/views/deferred/index.rhtml b/tracks/app/views/deferred/index.rhtml
new file mode 100644
index 00000000..7613ee4f
--- /dev/null
+++ b/tracks/app/views/deferred/index.rhtml
@@ -0,0 +1,16 @@
+
+
+ <% for name in ["notice", "warning", "message"] %>
+ <% if flash[name] %>
+ <%= "
#{flash[name]}
" %>
+ <% end %>
+ <% end %>
+
+ <%= render :partial => "items" %>
+
+
+
+
+ <%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %>
+ <%= render "shared/sidebar" %>
+
\ No newline at end of file
diff --git a/tracks/app/views/deferred/update.rjs b/tracks/app/views/deferred/update.rjs
new file mode 100644
index 00000000..2a3e26ab
--- /dev/null
+++ b/tracks/app/views/deferred/update.rjs
@@ -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
\ No newline at end of file
diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml
index 463d3a06..217c5ed2 100644
--- a/tracks/app/views/layouts/standard.rhtml
+++ b/tracks/app/views/layouts/standard.rhtml
@@ -43,10 +43,10 @@
- <%= navigation_link("Home", {:controller => "todo", :action => "list"}, {:accesskey => "t", :title => "Home"} ) %>
+ <%= navigation_link("Home", {:controller => "todo", :action => "index"}, {:accesskey => "t", :title => "Home"} ) %>
<%= navigation_link( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %>
<%= navigation_link( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %>
- <%= navigation_link( "Tickler", {:controller => "todo", :action => "tickler"}, :title => "Ticker" ) %>
+ <%= navigation_link( "Tickler", {:controller => "deferred", :action => "index"}, :title => "Ticker" ) %>
<%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %>
<%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "o", :title => "Show all notes"} ) %>
<%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %>
@@ -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 %>
diff --git a/tracks/app/views/shared/_add_new_item_form.rhtml b/tracks/app/views/shared/_add_new_item_form.rhtml
index 4bb32da8..b6a08b00 100644
--- a/tracks/app/views/shared/_add_new_item_form.rhtml
+++ b/tracks/app/views/shared/_add_new_item_form.rhtml
@@ -8,15 +8,15 @@
add_string = "Add a next action in this project »"
@selected_context = @contexts[0].id
@selected_project = @project.id
+ when "deferred"
+ add_string = "Add a deferred action »"
+ @selected_context = @contexts[0].id
+ @selected_project = nil
else
add_string = "Add a next action »"
@selected_context = @contexts[0].id
@selected_project = nil
- end
-
- if @on_page == "tickler"
- add_string = "Add a deferred action »"
- end
+ end
%>
<% hide_link ||= false %>
@@ -31,15 +31,15 @@
-<% 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 -%>
Description
<%= text_field( "todo", "description", "size" => 25, "tabindex" => 1) %>
@@ -59,7 +59,7 @@
Due
<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %>
-<% if @on_page == "tickler" -%>
+<% if controller.controller_name == "deferred" -%>
Show from
<%= text_field("todo", "show_from", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %>
<% end -%>
@@ -68,7 +68,7 @@
<%= end_form_tag %>
<%= calendar_setup( "todo_due" ) %>
-<% if @on_page == "tickler" -%>
+<% if controller.controller_name == "deferred" -%>
<%= calendar_setup( "todo_show_from" ) %>
<% end -%>
diff --git a/tracks/app/views/shared/_new_action_form.rhtml b/tracks/app/views/shared/_new_action_form.rhtml
index f8d7ba91..8c387321 100644
--- a/tracks/app/views/shared/_new_action_form.rhtml
+++ b/tracks/app/views/shared/_new_action_form.rhtml
@@ -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 »"
@selected_context = @context.id
- @selected_project = nil
when "project"
add_string = "Add a next action in this project »"
- @selected_context = @contexts[0].id
@selected_project = @project.id
- else
+ when "deferred"
add_string = "Add a next action »"
- @selected_context = @contexts[0].id
- @selected_project = nil
- end
-
- if @on_page == "tickler"
- add_string = "Add a deferred action »"
+ else
+ add_string = "Add a deferred action »"
end
%>
<% hide_link ||= false %>
@@ -57,7 +53,7 @@
<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onFocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %>
-<% if @on_page == "tickler" -%>
+<% if controller.controller_name == "tickler" -%>
Show from
<%= date_select( "todo", "show_from", :start_year => Date.today.year, :order => [:year, :month, :day] ) %>
diff --git a/tracks/app/views/todo/_tickle.rhtml b/tracks/app/views/todo/_tickle.rhtml
deleted file mode 100644
index cc0b4043..00000000
--- a/tracks/app/views/todo/_tickle.rhtml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- <%= link_to_remote_todo( tickle, controller.controller_name, "deferred" ) %>
-
- <%= 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 -%>
-
-
-
- <%= form_remote_tag_edit_todo( tickle, "deferred" ) -%>
- <% #note: edit form will load here remotely -%>
- <%= end_form_tag -%>
-
-
\ No newline at end of file
diff --git a/tracks/app/views/todo/deferred_update_action.rjs b/tracks/app/views/todo/deferred_update_action.rjs
deleted file mode 100644
index f51dece7..00000000
--- a/tracks/app/views/todo/deferred_update_action.rjs
+++ /dev/null
@@ -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
\ No newline at end of file
diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/index.rhtml
similarity index 100%
rename from tracks/app/views/todo/list.rhtml
rename to tracks/app/views/todo/index.rhtml
diff --git a/tracks/config/routes.rb b/tracks/config/routes.rb
index 72955254..35ed5e73 100644
--- a/tracks/config/routes.rb
+++ b/tracks/config/routes.rb
@@ -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'
diff --git a/tracks/public/images/menuarrow.gif b/tracks/public/images/menuarrow.gif
new file mode 100644
index 00000000..20fdf2b6
Binary files /dev/null and b/tracks/public/images/menuarrow.gif differ
diff --git a/tracks/public/stylesheets/calendar-system.css b/tracks/public/stylesheets/calendar-system.css
index 742a1c77..fedfa7e8 100644
--- a/tracks/public/stylesheets/calendar-system.css
+++ b/tracks/public/stylesheets/calendar-system.css
@@ -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" */