Author: assaf
Date: Mon Jun 2 21:53:09 2008
New Revision: 662647
URL: http://svn.apache.org/viewvc?rev=662647&view=rev
Log:
Added cancel, suspend, resume and delegate task actions.
Modified:
ode/sandbox/singleshot/app/helpers/task_helper.rb
ode/sandbox/singleshot/app/models/task.rb
ode/sandbox/singleshot/app/views/tasks/show.html.erb
ode/sandbox/singleshot/public/stylesheets/default.css
Modified: ode/sandbox/singleshot/app/helpers/task_helper.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/task_helper.rb?rev=662647&r1=662646&r2=662647&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/task_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/task_helper.rb Mon Jun 2 21:53:09 2008
@@ -40,4 +40,23 @@
content_tag 'iframe', '', :id=>'task_frame', :src=>uri.to_s
end
+ def task_actions(task)
+ actions = []
+ actions << button_to('Cancel', task_url(task,
'task[status]'=>'cancelled'), :method=>:put, :title=>'Cancel this task') if
task.can_cancel?(authenticated)
+ if task.can_suspend?(authenticated)
+ actions << button_to('Suspend', task_url(task,
'task[status]'=>'suspended'), :method=>:put, :title=>'Suspend this task',
:disabled=>task.suspended?)
+ actions << button_to('Resume', task_url(task, 'task[status]'=>'active'),
:method=>:put, :title=>'Resume this task', :disabled=>!task.suspended?)
+ end
+ if task.can_delegate?(authenticated)
+ others = task.potential_owners - [EMAIL PROTECTED]
+ unless others.empty?
+ actions << form_tag(task_url(task), :method=>:put,
:class=>'button-to') +
+ '<select name="task[owner]"><option disabled>Select owner
...</option>' +
+ options_for_select(others.map { |person| [person.fullname,
person.identity] }.sort) +
+ '</select><input type="submit" value="Delegate"></form>'
+ end
+ end
+ actions.join
+ end
+
end
Modified: ode/sandbox/singleshot/app/models/task.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/task.rb?rev=662647&r1=662646&r2=662647&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/task.rb (original)
+++ ode/sandbox/singleshot/app/models/task.rb Mon Jun 2 21:53:09 2008
@@ -324,6 +324,8 @@
self
end
+ LOG_CHANGE_ATTRIBUTES = [:title, :description, :priority, :due_on]
+
before_save :unless=>lambda { |task| task.status == 'reserved' } do |task|
task.log_activities do |log|
if task.status_changed?
@@ -335,13 +337,16 @@
log.add nil, 'released' if from == 'active'
when 'active'
log.add nil, 'resumed' if from == 'suspended'
- log.add task.owner, 'is owner of'
+ log.add task.owner, 'is owner of' if task.changed.include?('owner')
when 'suspended' then log.add nil, 'suspended'
when 'completed' then log.add task.owner, 'completed'
when 'cancelled' then log.add nil, 'cancelled'
end
- else
- log.add nil, 'modified'
+ elsif task.changed.include?('owner')
+ # TODO: get this working!
+ log.add task.owner, 'is owner of'
+ elsif task.changed.any? { |attr| LOG_CHANGE_ATTRIBUTES.include?(attr) }
+ log.add nil, 'changed'
end
end
end
@@ -423,15 +428,15 @@
end
def can_suspend?(person)
- admin?(person) # || person.admin?
+ admin?(person) && active? || ready? # || person.admin?
end
def can_claim?(person)
owner.nil? && potential_owner?(person)
end
- def can_assign_to?(person)
- !excluded_owner?(person)
+ def can_delegate?(person)
+ (owner?(person) && active?) || (admin?(person) && active? || ready?)
end
def filter_update_for(person)
Modified: ode/sandbox/singleshot/app/views/tasks/show.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/show.html.erb?rev=662647&r1=662646&r2=662647&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/show.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/show.html.erb Mon Jun 2 21:53:09
2008
@@ -4,6 +4,7 @@
%>
<% div_for @task do %>
<div class='header'>
+ <h1><%= link_to 'Singleshot', tasks_url, :title=>'Back to tasks list'
%></h1>
<div class='actions'>
<%= quick_actions(@task) %>
<%= content_tag 'button', 'More Options',
:onclick=>"Singleshot.expand(event, '.header .details', 'Less options')",
:class=>'button-to' %>
@@ -11,20 +12,18 @@
<div class='vitals'>
<%= task_vitals(@task) %>: <%= content_tag 'span', h(@task.title),
:class=>'title', :title=>@task.title %>
</div>
- <div class='details' style='display:none'>
- <%= link_to image_tag('calendar.png') + ' Calendar',
@alternate[Mime::ICS], :rel=>'alternate', :title=>'Add this task to your
calendar' %>
- <%= link_to image_tag('feed.png') + ' Activity', @alternate[Mime::ATOM],
:rel=>'alternate', :title=>'Subscribe to see changes to this task' %>
+ <div class='details' style='display:non'>
<dl>
<%= content_tag('dt', 'Description') + content_tag('dd',
sanitize(simple_format(@task.description))) unless use_description %>
<dt>Priority</dt><dd><%= ['High', 'Medium', 'Low'[EMAIL PROTECTED] -
1] %></dd>
- <%= content_tag('dt', 'Due on') + content_tag('dd',
relative_date(@task.due_on)) if @task.due_on %>
+ <%= content_tag('dt', 'Due on') + content_tag('dd',
relative_date(@task.due_on).humanize) if @task.due_on %>
<dt>Recent activity</dt>
- <dd><%= render :file=>'activities/_activities', :locals=>{
:today=>Date.today, :activities=>@task.activities } %></dd>
- <%= admins = @task.admins.map { |person| link_to_person(person,
:rel=>:admin) }
- content_tag('dt', 'Admins') + content_tag('dd',
admins.to_sentence) unless admins.empty? %>
- <%= observers = @task.observers.map { |person|
link_to_person(person, :rel=>:observer) }
- content_tag('dt', 'Observers') + content_tag('dd',
observers.to_sentence) unless observers.empty? %>
+ <dd>
+ <ul class='alternate'><%= content_tag 'li',
link_to(image_tag('feed.png') + ' Feed', @alternate[Mime::ATOM],
:rel=>'alternate', :title=>'Subscribe to see changes to this task') %><%=
content_tag 'li', link_to(image_tag('calendar.png') + ' Calendar',
@alternate[Mime::ICS], :rel=>'alternate', :title=>'Add this task to your
calendar') %></ul>
+ <%= render :file=>'activities/_activities', :locals=>{
:today=>Date.today, :activities=>@task.activities } %>
+ </dd>
</dl>
+ <div class='actions'><%= task_actions(@task) %></div>
</div>
</div>
Modified: ode/sandbox/singleshot/public/stylesheets/default.css
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/public/stylesheets/default.css?rev=662647&r1=662646&r2=662647&view=diff
==============================================================================
--- ode/sandbox/singleshot/public/stylesheets/default.css (original)
+++ ode/sandbox/singleshot/public/stylesheets/default.css Mon Jun 2 21:53:09
2008
@@ -98,7 +98,7 @@
/** Header **/
#header {
- background-color: #e0e0e0;
+ background-color: #fff;
padding: 0.5em 3em 3px 3em;
border-bottom: solid 2px #046380;
}
@@ -162,22 +162,28 @@
-moz-border-radius: 0.3em;
-webkit-border-top-left-radius: 0.3em;
}
-
#header ul.alternate {
+ margin-top: -1.3em;
+ font-size: 1.2em;
+}
+
+
+/** Feed and calendar links **/
+
+ul.alternate {
+ margin: 0;
list-style: none;
float: right;
position: relative;
- margin-top: -1.3em;
- font-size: 1.2em;
}
-#header ul.alternate li {
+ul.alternate li {
display: inline;
}
-#header ul.alternate a {
+ul.alternate a {
padding-left: 1em;
text-decoration: none;
}
-#header ul.alternate img {
+ul.alternate img {
border: none;
vertical-align: bottom;
margin: 0.1em;
@@ -278,6 +284,7 @@
div.task {
margin: 0;
padding: 0;
+ background-color: #fff;
}
div.task div.header {
position: absolute;
@@ -285,11 +292,19 @@
margin: 0;
padding: 0;
border-bottom: solid 2px #046380;
- background-color: #e0e0e0;
+}
+div.task div.header h1 {
+ display: inline;
+ float: left;
+ font-size: 1.1em;
+ margin: 0.6em 2em 0 2.5em;
+}
+div.task div.header h1 a {
+ color: #000;
}
div.task div.header div.vitals {
- margin: 0.6em 0em 0 3em;
+ margin: 0.6em 0 0 0;
font-size: 1.1em;
text-overflow: ellipsis;
overflow: hidden;
@@ -300,7 +315,7 @@
}
div.task div.header div.actions {
display: inline;
- background: #e0e0e0;
+ background: #fff;
float: right;
margin: 0.5em 2.5em 0.5em 0;
}
@@ -308,28 +323,32 @@
margin-left: 0.6em;
}
-div.task div.header div.details {
+div.task div.details {
clear: both;
- padding: 0em 3em 2em 3em;
+ padding: 1em 3em 2em 3em;
border-top: 1px solid #ccc;
margin: 0;
+ background-color: #fff;
}
-div.task div.header div.details a[rel=alternate] {
- float: right;
- padding-left: 1em;
- text-decoration: none;
-}
-div.task div.header div.details a[rel=alternate] img {
- border: none;
- vertical-align: bottom;
- margin: 0.1em;
-}
-div.task div.header div.details dt {
+div.task div.details dt {
font-weight: bold;
float: left;
+ position: relative;
+ display: inline;
}
-div.task div.header div.details dd {
+div.task div.details dd {
margin: 0 0 1em 10em;
+ min-height: 1.3em;
+}
+div.task div.details ol.activities {
+ margin: 0;
+}
+div.task div.details div.actions {
+ margin: 1em 0 1em 0;
+}
+div.task div.details div.actions select {
+ width: 10em;
+ margin: 0 0.6em 0 0.6em;
}
div.task div.description {
@@ -351,7 +370,6 @@
width: 100%;
margin: 0;
padding: 0.3em 3em 0.3em 3em;
- background-color: #e0e0e0;
border-top: solid 2px #046380;
}
div.task div.footer .actions {