Applied Luke's patch (#164) to decrease the size of the homepage and load the edit forms dynamically when the edit button is clicked. Thanks, Luke!

As a result, I'm going to redo the empty message changes I made in [164], and will see if I can find a more sensible way to implement them. The empty messages still appear (now also in the notes area if that's empty), but you need a refresh after Ajax changes to view or remove them.



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@165 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-12-04 11:43:09 +00:00
parent 8349e760b3
commit 80f3fdbc77
20 changed files with 265 additions and 496 deletions

View file

@ -56,8 +56,7 @@ class ApplicationController < ActionController::Base
# Okay, you get another hour
@session['expiry_time'] = Time.now + (60*60)
end
end
end
end
end
end

View file

@ -1,8 +1,6 @@
class ContextController < ApplicationController
helper :context
model :project
model :todo
helper :todo
before_filter :login_required
layout "standard"
@ -57,19 +55,6 @@ class ContextController < ApplicationController
render :text => ""
end
end
# Toggles the 'done' status of the action
#
def toggle_check
self.init
item = check_user_return_item
item.toggle!('done')
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
end
# Fairly self-explanatory; deletes the context
# If the context contains actions, you'll get a warning dialogue.
@ -84,7 +69,7 @@ class ContextController < ApplicationController
end
end
# Methods for changing the sort order of the projects in the list
# Methods for changing the sort order of the contexts in the list
#
def order
@params["list-contexts"].each_with_index do |id, position|
@ -96,16 +81,6 @@ class ContextController < ApplicationController
end
protected
def check_user_return_item
item = Todo.find( @params['id'] )
if @session['user'] == item.user
return item
else
flash["warning"] = "Item and session user mis-match: #{item.user.name} and #{@session['user'].name}!"
render_text ""
end
end
def check_user_set_context
@user = @session['user']

View file

@ -1,10 +1,10 @@
class ProjectController < ApplicationController
helper :project
model :context
model :todo
helper :todo
before_filter :login_required
layout "standard"
def index
@ -75,19 +75,6 @@ class ProjectController < ApplicationController
end
end
# Toggles the 'done' status of the action
#
def toggle_check
self.init
item = check_user_return_item
item.toggle!('done')
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
end
# Toggles the 'done' status of a project
#
def toggle_project_done
@ -124,16 +111,6 @@ class ProjectController < ApplicationController
protected
def check_user_return_item
item = Todo.find( @params['id'] )
if @session['user'] == item.user
return item
else
flash["warning"] = "Item and session user mis-match: #{item.user.name} and #{@session['user'].name}!"
render_text ""
end
end
def check_user_set_project
@user = @session['user']
if @params["name"]

View file

@ -1,7 +1,10 @@
class TodoController < ApplicationController
model :user
model :project
model :context
helper :todo
model :context, :project, :user
before_filter :login_required
layout "standard"
@ -21,41 +24,13 @@ class TodoController < ApplicationController
@page_title = "TRACKS::List tasks"
@done = @done[0..(NO_OF_ACTIONS-1)]
@contexts_to_show = @contexts.clone
@contexts_to_show = @contexts_to_show.collect {|x| (!x.hidden? and !x.find_not_done_todos.empty?) ? x:nil }.compact
# Set count badge to number of not-done, not hidden context items
@count = @todos.collect { |x| ( !x.done? and !x.context.hidden? ) ? x:nil }.compact.size
end
# List the completed tasks, sorted by completion date
#
# Use days declaration? 1.day.ago?
def completed
self.init
@page_title = "TRACKS::Completed tasks"
day = (60 * 60 * 24)
today = Time.now
today_date = today - (1 * day)
week_begin = today - (1 * day)
week_end = today - (7 * day)
month_begin = today - (8 * day)
month_end = today - (31 * day)
@done_today = @done.collect { |x| today_date <= x.completed ? x:nil }.compact
@done_this_week = @done.collect { |x| week_begin >= x.completed && week_end <= x.completed ? x:nil }.compact
@done_this_month = @done.collect { |x| month_begin >= x.completed && month_end <= x.completed ? x:nil }.compact
end
# Archived completed items, older than 31 days
#
def completed_archive
self.init
@page_title = "TRACKS::Archived completed tasks"
archive_date = Time.now - 32 * (60 * 60 * 24)
@done_archive = @done.collect { |x| archive_date >= x.completed ? x:nil }.compact
end
# Called by a form button
# Parameters from form fields are passed to create new action
# in the selected context.
@ -78,6 +53,26 @@ class TodoController < ApplicationController
end
end
def edit_action
self.init
item = check_user_return_item
render :partial => 'action_edit_form', :object => item
end
# Toggles the 'done' status of the action
#
def toggle_check
self.init
item = check_user_return_item
item.toggle!('done')
item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working
if item.save
render :partial => 'item', :object => item
end
end
# Edit the details of an action
#
def update_action
@ -112,19 +107,38 @@ class TodoController < ApplicationController
end
end
# Toggles the 'done' status of the action
# List the completed tasks, sorted by completion date
#
def toggle_check
# Use days declaration? 1.day.ago?
def completed
self.init
@page_title = "TRACKS::Completed tasks"
day = (60 * 60 * 24)
today = Time.now
today_date = today - (1 * day)
week_begin = today - (1 * day)
week_end = today - (7 * day)
month_begin = today - (8 * day)
month_end = today - (31 * day)
@done_today = @done.collect { |x| today_date <= x.completed ? x:nil }.compact
@done_this_week = @done.collect { |x| week_begin >= x.completed && week_end <= x.completed ? x:nil }.compact
@done_this_month = @done.collect { |x| month_begin >= x.completed && month_end <= x.completed ? x:nil }.compact
item = check_user_return_item
item.toggle!('done')
item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working
if item.save
render :partial => 'item', :object => item
end
end
# Archived completed items, older than 31 days
#
def completed_archive
self.init
@page_title = "TRACKS::Archived completed tasks"
archive_date = Time.now - 32 * (60 * 60 * 24)
@done_archive = @done.collect { |x| archive_date >= x.completed ? x:nil }.compact
end
protected
def check_user_return_item
@ -145,6 +159,6 @@ class TodoController < ApplicationController
@done = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 1", @user.id], :include => [:project], :order => "completed DESC")
# for some reason, this generates an error about anil object under 0.14.2
#@done = @todos.collect { |x| x.done? ? x:nil }.compact.sort! {|x,y| y.completed <=> x.completed }
end
end

View file

@ -32,59 +32,4 @@ module ApplicationHelper
name.to_s.gsub(/ /, "_")
end
# Check due date in comparison to today's date
# Flag up date appropriately with a 'traffic light' colour code
#
def due_date(due)
if due == nil
return ""
end
@now = Date.today
@days = due-@now
case @days
# overdue or due very soon! sound the alarm!
when -365..-1
"<a title='" + format_date(due) + "'><span class=\"red\">Overdue by " + (@days * -1).to_s + " days</span></a> "
when 0
"<a title='" + format_date(due) + "'><span class=\"amber\">Due Today</span></a> "
when 1
"<a title='" + format_date(due) + "'><span class=\"amber\">Due Tomorrow</span></a> "
# due 2-7 days away
when 2..7
"<a title='" + format_date(due) + "'><span class=\"orange\">Due in " + @days.to_s + " days</span></a> "
# more than a week away - relax
else
"<a title='" + format_date(due) + "'><span class=\"green\">Due in " + @days.to_s + " days</span></a> "
end
end
# Uses the 'staleness_starts' value from settings.yml (in days) to colour
# the background of the action appropriately according to the age
# of the creation date:
# * l1: created more than 1 x staleness_starts, but < 2 x staleness_starts
# * l2: created more than 2 x staleness_starts, but < 3 x staleness_starts
# * l3: created more than 3 x staleness_starts
#
def staleness(item)
if item.created_at < (ApplicationController::STALENESS_STARTS*3).days.ago
return "<div class=\"stale_l3\">"
elsif item.created_at < (ApplicationController::STALENESS_STARTS*2).days.ago
return "<div class=\"stale_l2\">"
elsif item.created_at < (ApplicationController::STALENESS_STARTS).days.ago
return "<div class=\"stale_l1\">"
else
return "<div class=\"description\">"
end
end
def calendar_setup( input_field )
str = "Calendar.setup({ ifFormat:\"#{ApplicationController::DATE_FORMAT}\""
str << ",firstDay:#{ApplicationController::WEEK_STARTS_ON},showOthers:true,range:[2004, 2010]"
str << ",step:1,inputField:\"" + input_field + "\",cache:true,align:\"TR\" })"
javascript_tag str
end
end

View file

@ -1,29 +1,36 @@
module TodoHelper
# Counts the number of uncompleted items in the selected context
# Counts the number of uncompleted items in the specified context
#
def count_items(context)
count = Todo.find_all("done=0 AND context_id=#{context.id}").length
end
def form_remote_tag_todo_notdone( item )
form_remote_tag( :url => url_for( :controller => "todo", :action => "toggle_check", :id => item.id ),
:html => { :id=> "checkbox-notdone-#{item.id}", :class => "inline-form" },
:update => "completed",
:position => "top",
:loading => "Form.disable('checkbox-notdone-#{item.id}');",
:complete => visual_effect(:fade, "item-#{item.id}-container")
)
end
def form_remote_tag_toggle_todo( item )
target_div = item.done? ? "new_actions" : "completed"
target_position = item.done? ? "bottom" : "top"
form_id = "checkbox-#{item.id}-form"
item_container_id = "item-#{item.id}-container"
loading_javascript = "Form.disable('#{form_id}');"
if item.done?
loading_javascript << visual_effect(:appear, "new_actions", :duration => 0.4)
end
success_javascript = " $('#{item_container_id}').setAttribute('id','#{item_container_id}-fading');"
success_javascript << visual_effect( :fade, "#{item_container_id}-fading",
{
:duration => 0.4,
:afterFinish => "function(effect) { Element.remove('#{item_container_id}-fading'); }"
})
def form_remote_tag_todo_done( item )
form_remote_tag( :url => url_for( :controller => "todo", :action => "toggle_check", :id => item.id ),
:html => { :id=> "checkbox-done-#{item.id}", :class => "inline-form" },
:update => "new_actions",
:position => "bottom",
:loading => "Form.disable('checkbox-done-#{item.id}');",
:complete => "Element.toggle('new_actions');new Effect.Fade('done-item-#{item.id}-container');"
)
:html => { :id=> "#{form_id}", :class => "inline-form item-checkmark-form" },
:update => target_div,
:position => target_position,
:loading => loading_javascript,
:success => success_javascript,
:complete => visual_effect( :highlight, item_container_id))
end
def form_remote_tag_edit_todo( item )
@ -33,27 +40,82 @@ module TodoHelper
:complete => visual_effect(:appear, "item-#{item.id}-container")
)
end
def link_to_remote_todo_notdone( item )
str = "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form');"
str << " new Effect.Appear('action-#{item.id}-edit-form');"
str << " Form.focusFirstElement('form-action-#{item.id}')"
link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
:update => "item-#{item.id}-container",
:loading => visual_effect(:fade, "item-#{item.id}-container"),
:url => { :controller => "todo", :action => "destroy_action", :id => item.id },
:confirm => "Are you sure that you want to delete the action, \'#{item.description}\'?") + " " +
link_to_function(image_tag( "blank", :title => "Edit action", :class => "edit_item"),
str ) + " "
def link_to_remote_todo( item )
str = link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
{
:update => "item-#{item.id}-container",
:loading => visual_effect(:fade, "item-#{item.id}-container"),
:url => { :controller => "todo", :action => "destroy_action", :id => item.id },
:confirm => "Are you sure that you want to delete the action, \'#{item.description}\'?"
},
{
:class => "icon"
}) + "\n"
if !item.done?
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 },
: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}')"
},
{
:class => "icon"
})
else
str << '<a class="icon">' + image_tag("blank") + "</a> "
end
str
end
# Uses the 'staleness_starts' value from settings.yml (in days) to colour
# the background of the action appropriately according to the age
# of the creation date:
# * l1: created more than 1 x staleness_starts, but < 2 x staleness_starts
# * l2: created more than 2 x staleness_starts, but < 3 x staleness_starts
# * l3: created more than 3 x staleness_starts
#
def staleness_class(item)
if item.due || item.done
return ""
elsif item.created_at < (ApplicationController::STALENESS_STARTS*3).days.ago
return " stale_l3"
elsif item.created_at < (ApplicationController::STALENESS_STARTS*2).days.ago
return " stale_l2"
elsif item.created_at < (ApplicationController::STALENESS_STARTS).days.ago
return " stale_l1"
else
return ""
end
end
def link_to_remote_todo_done( item )
link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
:update => "done-item-#{item.id}-container",
:loading => visual_effect(:fade, "done-item-#{item.id}-container"),
:url => { :controller => "todo", :action => "destroy_action", :id => item.id },
:confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) +
"<a>" + image_tag("blank") + "</a> "
# Check due date in comparison to today's date
# Flag up date appropriately with a 'traffic light' colour code
#
def due_date(due)
if due == nil
return ""
end
@now = Date.today
@days = due-@now
case @days
# overdue or due very soon! sound the alarm!
when -365..-1
"<a title='" + format_date(due) + "'><span class=\"red\">Overdue by " + (@days * -1).to_s + " days</span></a> "
when 0
"<a title='" + format_date(due) + "'><span class=\"amber\">Due Today</span></a> "
when 1
"<a title='" + format_date(due) + "'><span class=\"amber\">Due Tomorrow</span></a> "
# due 2-7 days away
when 2..7
"<a title='" + format_date(due) + "'><span class=\"orange\">Due in " + @days.to_s + " days</span></a> "
# more than a week away - relax
else
"<a title='" + format_date(due) + "'><span class=\"green\">Due in " + @days.to_s + " days</span></a> "
end
end
def toggle_show_notes( item )
@ -62,8 +124,16 @@ module TodoHelper
str << "')\" class=\"show_notes\" title=\"Show notes\">"
str << image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>"
m_notes = markdown( item.notes )
str << "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">"
str << "\n<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">"
str << m_notes + "</div>"
str
end
def calendar_setup( input_field )
str = "Calendar.setup({ ifFormat:\"#{ApplicationController::DATE_FORMAT}\""
str << ",firstDay:#{ApplicationController::WEEK_STARTS_ON},showOthers:true,range:[2004, 2010]"
str << ",step:1,inputField:\"" + input_field + "\",cache:true,align:\"TR\" })"
javascript_tag str
end
end

View file

@ -1,42 +1,7 @@
<div id="display_box">
<div class="contexts">
<h2><%= sanitize(@context.name) %></h2>
<div id="next_actions">
<% if @not_done.empty? -%>
<div id="empty-nd" style="display:block;">
<%= render :partial => "empty",
:locals => { :message => "There are currently no uncompleted actions in this context"} %>
</div>
<% else -%>
<div id="empty-nd" style="display:none;">
<%= render :partial => "empty",
:locals => { :message => "There are currently no uncompleted actions in this context"} %>
</div>
<% end -%>
<%= render :partial => "show_items", :collection => @not_done %>
</div><!-- [end:next_actions] -->
</div><!-- [end:contexts] -->
<div class="contexts">
<h2>Completed actions in this context</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 context"} %>
</div>
<% else -%>
<div id="empty-nd" style="display:none;">
<%= render :partial => "empty",
:locals => { :message => "There are currently no uncompleted actions in this context"} %>
</div>
<% end -%>
<%= render :partial => "show_items", :collection => @done %>
</div>
</div><!-- [end:contexts] -->
<%= render :partial => "context/context", :locals => { :context => @context, :collapsible => false } %>
<%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context" } %>
</div><!-- [end:display_box] -->

View file

@ -9,6 +9,7 @@
<%= stylesheet_link_tag 'calendar-system.css' %>
<%= javascript_include_tag 'calendar', 'calendar-en', 'calendar-setup' %>
<%= javascript_include_tag "accesskey-hints" %>
<%= javascript_include_tag "todo-items" %>
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
<%= auto_discovery_link_tag(:rss,{:controller => "feed", :action => "na_feed", :name => "#{@session['user']['login']}", :token => "#{@session['user']['word']}"}, {:title => "RSS feed of next actions"}) %>

View file

@ -8,11 +8,11 @@
<div class="note_footer">
<%= link_to_remote( image_tag("blank", :title =>"Delete this note", :class=>"delete_item"),
:update => "note-#{note.id}",
:loading => "new Effect.Fade('note-#{note.id}-container', true)",
:loading => visual_effect(:fade, "note-#{note.id}-container"),
:complete => "Element.remove('note-#{note.id}-wrapper');",
:url => { :controller => "note", :action => "delete", :id => note.id },
:confirm => "Are you sure that you want to delete the note \'#{note.id.to_s}\'?" ) + "&nbsp;"%><%= link_to_function(image_tag( "blank", :title => "Edit item", :class=>"edit_item"),
"Element.toggle('note-#{note.id}','note-#{note.id}-edit-form'); new Effect.Appear('note-#{note.id}-edit-form'); Form.focusFirstElement('form-note-#{note.id}');" ) + " | " %>
"Element.toggle('note-#{note.id}','note-#{note.id}-edit-form'); Effect.Appear('note-#{note.id}-edit-form'); Form.focusFirstElement('form-note-#{note.id}');" ) + " | " %>
<%= link_to("In: " + note.project.name, {:controller => "project", :action => "show", :name => urlize(note.project.name)}, :class=>"footer_link" ) %>&nbsp;|&nbsp;
Created: <%= format_date(note.created_at) %>
<% if note.updated_at? -%>
@ -25,7 +25,7 @@
<%= form_remote_tag :url => { :action => 'update', :id => note.id },
:html => { :id => "form-note-#{note.id}", :class => "inline-form" },
:update => "note-#{note.id}-container",
:complete => "new Effect.appear('note-#{note.id}-container');" %>
:complete => visual_effect(:appear, "note-#{note.id}-container") %>
<%= render_partial "note_edit_form", note %>
<%= end_form_tag %>
</div><!-- [end:action-item.id-edit-form] -->

View file

@ -1,7 +1,7 @@
<% note = notes_summary -%>
<div class="note_wrapper">
<%= link_to( image_tag("blank"), { :controller => "note", :action => "show",
:id => note.id}, :title => "Show note", :class => "show_notes" ) %>&nbsp;
<%= link_to( image_tag("blank", :border => 0), { :controller => "note", :action => "show",
:id => note.id}, :title => "Show note", :class => "show_notes icon") %>&nbsp;
<%= sanitize(textilize(truncate(note.body, 50, "..."))) %>
</div>
<% note = nil -%>

View file

@ -1,6 +1,6 @@
<div id="display_box_projects">
<% for notes in @all_notes -%>
<div class="contexts" id="note-<%= notes.id %>-wrapper">
<div class="container" id="note-<%= notes.id %>-wrapper">
<%= render_partial "notes", notes %>
</div>
<% end -%>

View file

@ -1,5 +1,5 @@
<div id="display_box_projects">
<div class="contexts" id="note-<%= @note.id %>-wrapper">
<div class="container" id="note-<%= @note.id %>-wrapper">
<%= render_partial "notes", @note %>
</div>
</div>

View file

@ -1,51 +1,18 @@
<div id="display_box">
<div class="contexts">
<h2><%= sanitize(@project.name) %></h2>
<% if @project.description -%>
<div class="project_description"><%= sanitize(@project.description) %></div>
<% end -%>
<%= render :partial => "project/project", :locals => { :project => @project, :collapsible => false } %>
<%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this project" } %>
<% 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 -%>
<%= render :partial => "show_items", :collection => @not_done %>
</div><!-- [end:next_actions] -->
</div><!-- [end:contexts] -->
<div class="contexts">
<h2>Completed actions in this project</h2>
<div id="completed">
<% if @msg_d -%>
<div id="message-done" class="message" style="display: block;">
<p><%= @msg_d %></p>
</div>
<% end -%>
<%= render :partial => "show_items", :collection => @done %>
</div>
</div><!-- [end:contexts] -->
<!-- begin div.contexts -->
<div class="contexts">
<div class="container">
<div id="notes">
<h2>Notes</h2>
<% if @msg_n -%>
<div id="message-notes" class="message" style="display: block;">
<p><%= @msg_n %></p>
</div>
<% end -%>
<div id="empty-n" style="display:<%= @notes.empty? ? 'block' : 'none'%>;">
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no notes attached to this project"} %>
</div>
<%= render :partial => "note/notes_summary", :collection => @notes %>
</div>
</div>
<!-- end div.contexts -->
<% if @project.done? -%>
<%= button_to "Mark project as uncompleted", {:action => "toggle_project_done", :id => @project.id} %><br />
@ -59,8 +26,7 @@
<%= form_remote_tag :url => { :controller => "note", :action => "add" },
:update => "notes",
:position => "bottom",
:complete => "new Effect.Highlight('notes');
Element.hide('message-notes');",
:complete => "new Effect.Highlight('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

@ -2,10 +2,10 @@
case controller.controller_name
when "context"
add_string = "Add a next action in this context &#187;"
update_div = "next_actions"
update_div = "c" + @context.id.to_s
when "project"
add_string = "Add a next action in this project &#187;"
update_div = "next_actions"
update_div = "p" + @project.id.to_s
else
add_string = "Add a next action &#187;"
update_div = "new_actions"
@ -14,7 +14,7 @@
<%= link_to_function(
add_string,
"Element.toggle('todo_new_action');Form.focusFirstElement('todo-form-new-action');Element.toggle('new_actions');",
"Element.toggle('todo_new_action');Form.focusFirstElement('todo-form-new-action');",
{:title => "Add the next action", :accesskey => "n"}) %>
<div id="todo_new_action" class="context_new" style="display:none">
@ -23,8 +23,8 @@
:url => { :controller => "todo", :action => "add_item" },
:update => update_div,
:position => "bottom",
:complete => "Form.focusFirstElement('todo-form-new-action');
Element.remove('message-notdone');",
:loading => "ensureVisibleWithEffectAppear('#{update_div}');",
:complete => "Form.focusFirstElement('todo-form-new-action');",
:html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) %>
<label for="new_item_description">Description</label><br />

View file

@ -1,66 +1,32 @@
<% if !item.done? %>
<div id="item-<%= item.id %>-container">
<%= form_remote_tag_todo_notdone( item ) %>
<div id="item-<%= item.id %>">
<div class="big-box">
<%= link_to_remote_todo_notdone( item ) %>
</div>
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
</div>
<!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc -->
<% if item.due %>
<div class="description">
<% else %>
<%= staleness( item ) %>
<% end %>
<%= due_date( item.due ) %>
<%= sanitize(item.description) %>
<% if @params["project"] == "true" %>
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %>
<% else %>
<% if item.project_id %>
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>
<% end %>
<% end %>
<% if item.notes? %>
<%= toggle_show_notes( item ) %>
<% end %>
</div>
</div><!-- [end:item-item.id] -->
<%= end_form_tag %>
<div id="action-<%= item.id %>-edit-form" class="edit-form" style="display:none;">
<%= form_remote_tag_edit_todo( item ) %>
<%= render :partial => 'todo/action_edit_form', :object => item %>
<%= end_form_tag %>
</div><!-- [end:action-item.id-edit-form] -->
</div><!-- [end:item-item.id-container] -->
<% else %>
<div id="done-item-<%= item.id %>-container">
<%= form_remote_tag_todo_done( item ) %>
<div id="done-item-<%= item.id %>">
<div class="big-box"> <%= link_to_remote_todo_done( item ) %></div><!-- [end:big-box] -->
<!-- begin div.checkbox -->
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
</div>
<!-- end div.checkbox -->
<div class="description">
<span class="grey"><%= format_date( item.completed ) %></span>
<%= sanitize(item.description) %>
<% 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><!-- [end:description] -->
<div id="item-<%= item.id %>-container" class="item-container">
<div id="item-<%= item.id %>">
<%= form_remote_tag_toggle_todo( item ) %>
<%= form_tag( { :controller => "todo", :action => "toggle_check", :id => item.id },
{ :class => "inline-form" }) %>
<%= link_to_remote_todo( item ) %>
<input type="checkbox" class="item-checkbox" name="item_id" value="<%= item.id %>"<% if item.done? %> checked="checked" <% end %> />
<div class="description<%= staleness_class( item ) %>"><% # start of div which has a class 'description', and possibly 'stale_11', 'stale_12', 'stale_13' etc %>
<% if item.done? -%>
<span class="grey"><%= format_date( item.completed ) %></span>
<% else -%>
<%= due_date( item.due ) -%>
<% end -%>
<%= sanitize(item.description) %>
<% if project -%>
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %>
<% elsif 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>
<%= end_form_tag %>
</div><!-- [end:item-item.id] -->
<%= end_form_tag %>
</div><!-- [end:item-item.id-container] -->
<% end %>
<div id="action-<%= item.id %>-edit-form" class="edit-form" style="display:none;">
<%= form_remote_tag_edit_todo( item ) -%>
<% #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

@ -1,20 +1,20 @@
<div id="display_box_projects">
<p>You have completed <%= @done_today.length %> actions so far today.</p>
<div class="contexts">
<div class="container">
<h2>Completed today</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render :partial => "done", :collection => @done_today %>
</table>
</div>
<div class="contexts">
<div class="container">
<h2>Completed in last 7 days</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render :partial => "done", :collection => @done_this_week %>
</table>
</div>
<div class="contexts"
<div class="container">
<h2>Completed in the last 31 days</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render :partial => "done", :collection => @done_this_month %>

View file

@ -1,7 +1,7 @@
<div id="display_box_projects">
<p>There are <%= @done_archive.length %> completed actions in the archive.</p>
<div class="contexts">
<div class="container">
<h2>Completed more than 31 days ago</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render :partial => "done", :collection => @done_archive %>

View file

@ -1,41 +1,16 @@
<div id="display_box">
<!-- begin div.new_actions -->
<div id="new_actions" class="new_actions" style="display:none">
<div id="new_actions" class="next_actions container" style="display:none">
<h2>Fresh actions (hit <a href="javascript:window.location.reload()">refresh</a> to sort)</h2>
</div>
<!-- end div.new_actions -->
<%
for @context in @contexts
next if @context.hidden?
@not_done = @context.find_not_done_todos
next if @not_done.empty?
-%>
<div class="contexts">
<h2><a href="javascript:toggleSingle('c<%=@context.id%>');javascript:toggleImage('toggle_context_<%=@context.id%>')" class="refresh"><%= image_tag("collapse.png", :name=>"toggle_context_#{@context.id}", :border=>"0") %></a>
<%= link_to( sanitize("#{@context.name}"), :controller => "context", :action => "show", :name => urlize(@context.name) ) %></h2>
<div id="c<%= @context.id %>" class="next_actions">
<%= render :partial => "item", :collection => @not_done %>
</div><!-- [end:next_actions] -->
</div><!-- [end:contexts] -->
<% end -%>
<div class="contexts">
<h2>Completed actions</h2>
<div id="completed">
<% if @done.empty? -%>
<p>There are no completed next actions</p>
<% else -%>
<%= render :partial => "item", :collection => @done %>
<% end -%>
</div>
</div><!-- [end:contexts] -->
</div>
<%= render :partial => "context/context", :collection => @contexts_to_show,
:locals => { :collapsible => true } %>
<%= render :partial => "todo/completed",
:locals => { :done => @done, :collapsible => true, :append_descriptor => nil } %>
</div><!-- End of display_box -->
<div id="input_box">
<%= render "shared/add_new_item_form" %>
<%= render "shared/sidebar" %>
<%= render "shared/add_new_item_form" %>
<%= render "shared/sidebar" %>
</div><!-- End of input box -->
<% if @flash["confirmation"] -%>

View file

@ -1,50 +1,7 @@
function toggleAll(itemname,state) {
tmp = document.getElementsByTagName('div');
for (i=0;i<tmp.length;i++) {
if (tmp[i].className == itemname) tmp[i].style.display = state;
}
}
// Contributed by Andrew Williams
function toggleSingle(idname)
{
document.getElementById(idname).style.display = (document.getElementById(idname).style.display == 'none') ? 'block' : 'none';
}
function toggleAllImages()
{
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++)
{
var str = cookies[i].split('=')[0];
if(str.indexOf('toggle_context_') != -1)
{
var id = str.split('_')[2];
if(getCookie(str) == 'collapsed')
{
toggleSingle('c'+id);
toggleImage('toggle_context_'+id);
}
}
}
}
function toggleImage(idname)
{
if(document.images)
{
if(document[idname].src.indexOf('collapse.png') != -1)
{
document[idname].src = '/images/expand.png';
SetCookie(idname, "collapsed");
}
else
{
document[idname].src = '/images/collapse.png';
SetCookie(idname, "expanded");
}
function toggleAll(className,state) {
var elems = document.getElementsByClassName(className);
for (var i = 0; i < elems.length; i++) {
elems[i].style.display = state;
}
}
@ -75,50 +32,4 @@ var bikky = document.cookie;
}
//
// XMLHTTPRequest code from David Goodlad <http://hieraki.goodlad.ca/read/book/1>
//
function createXMLHttpRequest() {
try {
// Attempt to create it "the Mozilla way"
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
// Guess not - now the IE way
if (window.ActiveXObject) {
return new ActiveXObject(getXMLPrefix() + ".XmlHttp");
}
}
catch (ex) {}
return false;
};
// Move item from uncompleted to completed
// Many thanks to Michelle at PXL8 for a great tutorial:
// <http://www.pxl8.com/appendChild.html>
function moveRow(id){
// -- get the table row correstponding to the selected item
var m1 = document.getElementById(id);
if (m1)
// -- append it to the 1st tbody of table id="holding"
document.getElementById('holding').getElementsByTagName('tbody')[0].appendChild(m1);
}
function markItemDone(rowId, uri, id) {
var req = createXMLHttpRequest();
moveRow(rowId);
if(!req) {
return false;
}
req.open("POST", uri, true); //POST asynchronously
req.setRequestHeader('Content-Type', 'application/x-www-form-url-encoded; charset=UTF-8');
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
}
}
req.send(encodeURIComponent("id") + '=' + encodeURIComponent(id));
};

View file

@ -57,7 +57,7 @@ a.show_notes:hover {background-image: url(../images/notes_on.png); background-re
width: 450px;
margin: 0px 15px 50px 15px;
}
#full_width_display {
float: left;
width: 800px;
@ -108,14 +108,14 @@ a.show_notes:hover {background-image: url(../images/notes_on.png); background-re
#navlist a:hover { color: #000; }
.contexts {
.container {
padding: 0px 5px 0px 5px;
border: 1px solid #999;
margin: 0px 0px 15px 0px;
background: #fff;
}
.contexts h2 {
.container h2 {
background: #CCC;
padding: 5px;
margin-top: 0px;
@ -126,6 +126,12 @@ a.show_notes:hover {background-image: url(../images/notes_on.png); background-re
text-shadow: rgba(0,0,0,.4) 0px 2px 5px;
}
.container_toggle img {
height:20px;
width:20px;
border:0px;
}
/* Styling the 'Fresh Actions' box on the home page */
#new_actions {
padding: 0px 5px 2px 5px;
@ -138,6 +144,7 @@ a.show_notes:hover {background-image: url(../images/notes_on.png); background-re
#new_actions h2 {
/* padding: 0 px 5px 0px 5px; */
color: #57A620;
background: transparent;
text-align: center;
}
@ -173,19 +180,24 @@ h2 a:hover {
width: 20px;
}
div.big-box, div.big-box a, div.big-box a:hover {
float: left;
.container a.icon {
float: left;
vertical-align: middle;
background-color: transparent;
}
.checkbox {
float: left;
input.item-checkbox {
float: left;
margin-left: 10px;
vertical-align: middle;
}
.checkbox form {
display: inline;
margin: 0;
}
.description {
.description, .stale_l1, .stale_l2, .stale_l3 {
margin-left: 70px;
margin-right: 10px;
}
@ -278,7 +290,7 @@ a.footer_link:hover {color: #fff; background-color: #cc3334 !important;}
text-align: center;
}
.completed {
.project_completed {
border: 1px solid #007E00;
background-color: #c2ffc2;
padding: 5px;
@ -335,21 +347,15 @@ a.footer_link:hover {color: #fff; background-color: #cc3334 !important;}
The colour of the background gets progressively yellower with age */
.stale_l1 {
margin-left: 70px;
margin-right: 10px;
background: #ffffCC;
background: #ffC;
}
.stale_l2 {
margin-left: 70px;
margin-right: 10px;
background: #ffff66;
background: #ff6;
}
.stale_l3 {
margin-left: 70px;
margin-right: 10px;
background: #ffff00;
background: #ff0;
}
@ -430,7 +436,7 @@ div#list-projects, div#list-contexts {
border: 1px solid #999;
}
.next_actions td {
.container td {
border: none;
padding-bottom: 5px;
}
@ -458,7 +464,7 @@ form {
width: 313px;
}
.inline-form {
.inline-form, .item-checkmark-form {
border: none;
padding: 3px;
width: 100%;
@ -501,7 +507,6 @@ input, select {
cursor: move;
}
div.message {
margin: 5px 0px;
background: #FAF4B5;