Author: assaf
Date: Fri May 16 01:38:18 2008
New Revision: 656968
URL: http://svn.apache.org/viewvc?rev=656968&view=rev
Log:
Added relative_date to tasks lists and enhanced task lists feed.
Modified:
ode/sandbox/singleshot/app/helpers/application_helper.rb
ode/sandbox/singleshot/app/helpers/task_helper.rb
ode/sandbox/singleshot/app/views/tasks/index.atom.builder
ode/sandbox/singleshot/app/views/tasks/index.html.erb
ode/sandbox/singleshot/lib/extensions/ical_template.rb
ode/sandbox/singleshot/public/stylesheets/default.css
Modified: ode/sandbox/singleshot/app/helpers/application_helper.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/application_helper.rb?rev=656968&r1=656967&r2=656968&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/application_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/application_helper.rb Fri May 16
01:38:18 2008
@@ -5,22 +5,31 @@
# (or profile, if unspecified) as the reference.
def link_to_person(person, options = {})
fullname = h(person.fullname)
- fullname = '<<unknown;>' if fullname.blank?
- person.site_url ? link_to(fullname, person.site_url,
options.reverse_merge(:title=>"See #{fullname}'s profile")) :
+ person.identity ? link_to(fullname, person.identity,
options.reverse_merge(:title=>"See #{fullname}'s profile")) :
content_tag('span', fullname, options)
end
# Returns Person object for currently authenticated user.
attr_reader :authenticated
- def relative_date_with_adjustment(date)
- date = date.utc if Time === date
- relative_date(date)
+ def relative_date(date)
+ date = date.to_date
+ today = Date.today
+ if date == today
+ 'Today'
+ elsif date == today - 1.day
+ 'Yesterday'
+ elsif date.cweek == today.cweek
+ date.strftime('%A')
+ elsif date.year == today.year
+ date.strftime('%B %d')
+ else
+ date.strftime('%B %d, %Y')
+ end
end
- def relative_date_with_abbr(date)
- date = date.utc if Time === date
- content_tag 'abbr', h(relative_date(date)), :title=>date.to_date.to_s
+ def relative_date_abbr(date)
+ content_tag 'abbr', relative_date(date), :title=>date.to_date.to_s
end
end
Modified: ode/sandbox/singleshot/app/helpers/task_helper.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/task_helper.rb?rev=656968&r1=656967&r2=656968&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/task_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/task_helper.rb Fri May 16 01:38:18 2008
@@ -1,5 +1,23 @@
module TaskHelper
+ def task_actions(task)
+ actions = []
+ actions << button_to('Manage', edit_task_url(task), :method=>:get,
:title=>'Edit task') if task.admin?(authenticated)
+ actions << button_to('Cancel', task_url(task), :method=>:delete,
:title=>'Cancel this task') if task.can_cancel?(authenticated)
+ actions << button_to('Claim', task_url(task,
'task[owner]'=>authenticated.identity), :method=>:put,
+ :title=>'Claim task',
:disabled=>!task.can_claim?(authenticated)) if task.active? || task.ready?
+ actions.join(' ')
+ end
+
+ def task_vitals(task)
+ vitals = ['Created ' + relative_date_abbr(task.created_at)]
+ vitals.first << ' by ' + link_to_person(task.creator) if task.creator
+ vitals << (task.status == 'completed' ? "completed by " : "assigned to ")
+ link_to_person(task.owner) if task.owner
+ vitals << "due on #{task.due_on.to_formatted_s(:long)}" if task.due_on
+ vitals.to_sentence
+ end
+
+
def task_bar_vitals(task, person = authenticated)
case task.status
when :suspended
@@ -23,13 +41,6 @@
Array(vitals).join(', ').gsub(/^\w/) { |w| w.upcase }
end
- def task_bar_actions(task, person = authenticated)
- if task.active? && task.can_claim?(person)
- button_to('Claim Task', task_url(task, 'task[owner]'=>person.to_param),
:method=>:put,
- :title=>'Claim ownership and perform this task')
- end
- end
-
def task_iframe_url(task, person = authenticated)
task_uri = URI(task_url(task))
task_uri.user, task_uri.password = '_token', task.token_for(person)
Modified: ode/sandbox/singleshot/app/views/tasks/index.atom.builder
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/index.atom.builder?rev=656968&r1=656967&r2=656968&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/index.atom.builder (original)
+++ ode/sandbox/singleshot/app/views/tasks/index.atom.builder Fri May 16
01:38:18 2008
@@ -7,7 +7,8 @@
entry.title task.title
entry.content :type=>'html' do |content|
content.text! "<p>#{h(task.description)}</p>"
- # TODO: task stats and actions
+ content.text! "<p><em>#{task_vitals(task)}</em></p>"
+ content.text! "<div>#{task_actions(task)}</div>"
end
end
end
Modified: ode/sandbox/singleshot/app/views/tasks/index.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/index.html.erb?rev=656968&r1=656967&r2=656968&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/index.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/index.html.erb Fri May 16 01:38:18
2008
@@ -1,22 +1,14 @@
<ol class='tasks'>
<% @tasks.each do |task| %>
<% content_tag_for 'li', task do %>
- <div class='actions'>
- <%= button_to 'Edit', edit_task_url(task), :method=>:get,
:title=>'Edit task' if task.admin?(authenticated) %>
+ <div class='actions'><%= task_actions(task) %>
+ <%= button_to 'Manage', edit_task_url(task), :method=>:get,
:title=>'Edit task' if task.admin?(authenticated) %>
<%= button_to 'Cancel', task_url(task), :method=>:delete,
:title=>'Cancel this task' if task.can_cancel?(authenticated) %>
<%= button_to 'Claim', task, :title=>'Claim task',
:disabled=>!task.can_claim?(authenticated) if task.active? || task.ready? %>
</div>
<h3 class='title priority_<%= task.priority %> <%= 'overdue' if
task.over_due? %>'><%= link_to h(task.title), task_url(task),
:title=>'View/perform task' %></h3>
<p class='description'><%= h(task.description) %></p>
- <p class='stats'>
- <%=
- stats = ['Created ' + task.created_at.to_date.to_formatted_s(:long)]
- stats << 'by ' + link_to(task.creator.fullname, task.creator.identity)
if task.creator
- stats << 'assigned to ' + link_to(task.owner.fullname,
task.owner.identity) if task.owner
- stats << "due on #{task.due_on.to_formatted_s(:long)}" if task.due_on
- stats.to_sentence
- %>
- </p>
+ <p class='vitals'><%= task_vitals(task) %></p>
<% end %>
<% end %>
</ol>
Modified: ode/sandbox/singleshot/lib/extensions/ical_template.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/lib/extensions/ical_template.rb?rev=656968&r1=656967&r2=656968&view=diff
==============================================================================
--- ode/sandbox/singleshot/lib/extensions/ical_template.rb (original)
+++ ode/sandbox/singleshot/lib/extensions/ical_template.rb Fri May 16 01:38:18
2008
@@ -5,7 +5,6 @@
def initialize(request, record = nil)
@properties = {}
- # TODO: created, last-mod, uid
if record
uid "#{request.host}:#{record.class}/#{record.id}"
dtstamp record.created_at.utc.strftime('%Y%m%dT%H%M%SZ') if
record.respond_to?(:created_at)
@@ -17,6 +16,9 @@
attr_accessor :properties
def to_ical
+ # TODO: escaping for values
+ # TODO: break up long lines
+ # TODO: all other conformance requirements
properties = @properties.map { |name, value| property(name, value) }
"BEGIN:#{self.class.const_get
:NAME}\n#{properties.join("\n")}\nEND:#{self.class.const_get :NAME}"
end
@@ -83,6 +85,7 @@
end
def to_ical
+ # TODO: user's timezone
"BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:[EMAIL
PROTECTED](&:to_ical).join("\n")}\nEND:VCALENDAR\n"
end
end
Modified: ode/sandbox/singleshot/public/stylesheets/default.css
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/public/stylesheets/default.css?rev=656968&r1=656967&r2=656968&view=diff
==============================================================================
--- ode/sandbox/singleshot/public/stylesheets/default.css (original)
+++ ode/sandbox/singleshot/public/stylesheets/default.css Fri May 16 01:38:18
2008
@@ -261,7 +261,7 @@
ol.tasks li.task .actions form {
margin-left: 0.1em;
}
-ol.tasks li.task p.stats {
+ol.tasks li.task p.vitals {
color: #808080;
}