action_plans.no_action_plan=No action plan
action_plans.no_reviews_linked_to_action_plan=No reviews linked to this action plan yet.
action_plans.confirm_delete=Delete this action plan? Associated reviews will not be deleted.
+action_plans.confirm_close=Close this action plan? There are still open reviews linked to it.
action_plans.create_new_action_plan=Create a new action plan
action_plans.date_format_help=The date should be entered using the following pattern: 'day/month/year'. For instance, '31/12/2011'.
action_plans.date_not_valid=Date not valid
# GET
def action_plan_form
@review = Review.find(params[:id])
- @action_plans = ActionPlan.by_project_id(@review.project_id)
+ @action_plans = ActionPlan.open_by_project_id(@review.project_id)
render :partial => 'reviews/action_plan_form'
end
# GET
def violation_action_plan_form
@violation = RuleFailure.find(params[:id], :include => ['review', 'snapshot'])
- @action_plans = ActionPlan.by_project_id(@violation.snapshot.root_project_id)
+ @action_plans = ActionPlan.open_by_project_id(@violation.snapshot.root_project_id)
render :partial => 'reviews/violation_action_plan_form'
end
STATUS_OPEN = 'OPEN'
STATUS_CLOSED = 'CLOSED'
- def self.by_project_id(project_id)
- ActionPlan.find :all, :conditions => ['project_id=?', project_id], :order => :name
+ def self.open_by_project_id(project_id)
+ ActionPlan.find :all, :conditions => ['status=? AND project_id=?', STATUS_OPEN, project_id], :order => :name
end
def user
open_reviews = reviews.select{|r| r.open? || r.reopened?}.size
{:total => total_reviews, :open => open_reviews, :resolved => total_reviews-open_reviews}
end
+
+ def has_open_reviews?
+ reviews.select {|r| r.open? || r.reopened?}.size > 0
+ end
+
+ def over_due?
+ dead_line ? dead_line.past? : false
+ end
private
-<style type="text/css">
- #actionPlans td {
- vertical-align: top;
- }
- #actionPlans td.progress {
- width: 300px;
- padding: 0px 40px;
- }
- #actionPlans td.noprogress {
- color: #777777;
- font-size: 93%;
- padding-left: 40px;
- padding-right: 40px;
- }
-</style>
-
<div class="line-block marginbottom10">
<ul class="operations">
<li class="last">
<tr>
<td class="thin nowrap center"><img src="<%= ApplicationController.root_context -%>/images/status/<%= plan.status -%>.png" title="<%= message(plan.status.downcase).capitalize -%>"/></td>
<td class="thin nowrap"><%= h(plan.name) -%></td>
- <td class="thin nowrap" align="right" x="<%= plan.dead_line ? plan.dead_line.tv_sec : '' -%>"><%= plan.dead_line ? l(plan.dead_line) : ' ' -%></td>
+ <td class="thin nowrap <%= 'over-due' if plan.over_due? -%>" align="right" x="<%= plan.dead_line ? plan.dead_line.tv_sec : '' -%>"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' ' -%></td>
<% if plan.progress[:total]==0 %>
<td class="noprogress thin nowrap">
<%= message('action_plans.no_reviews_linked_to_action_plan') -%>
<td id="desc"><%= h(plan.user.name) -%></td>
<td class="thin nowrap">
<% if plan.open? %>
- <%= link_to message('edit'), {:action => 'new', :id => @resource.id, :plan_id => plan.id}, {:class => 'action'} -%>
+ <%= link_to message('edit'), {:action => 'new', :id => @resource.id, :plan_id => plan.id}, {:class => 'action'} -%>
<% end %>
+ <%
+ close_confirmation_message = {}
+ if plan.open? && plan.has_open_reviews?
+ close_confirmation_message = {:confirm => message('action_plans.confirm_close')}
+ end
+ %>
<%= link_to plan.open? ? message('action_plans.close') : message('action_plans.reopen'),
- {:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'} -%>
+ {:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'}.merge(close_confirmation_message) -%>
<%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'action'} -%>
</td>
</tr>