]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2662 Various improvements on action plans
authorFabrice Bellingard <bellingard@gmail.com>
Mon, 19 Dec 2011 16:00:42 +0000 (17:00 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Mon, 19 Dec 2011 16:55:25 +0000 (17:55 +0100)
- Should not be possible to link a review to a closed action plan
- Display a message when about to close an action plan that has open
  reviews
- Display the date in red if the dead-line is in the past

plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
sonar-server/src/main/webapp/stylesheets/style.css

index ee60aff5462fec928d5a4432817492e0607b2ef9..a4c273918e92d8c1b08652c3dc9a867a58d26d33 100644 (file)
@@ -426,6 +426,7 @@ action_plans.col.operations=Operations
 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
index 65ac6dfa25e587c2a9a2c8c4c2e1d0fe2d641812..f0c1c446bb74402ba806b81187b531aca1980e0c 100644 (file)
@@ -190,7 +190,7 @@ class ReviewsController < ApplicationController
   # 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
   
@@ -382,7 +382,7 @@ class ReviewsController < ApplicationController
   # 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
   
index 847178da0c7163e1fa55bca50085a0a90df8f858..48a72017e24f06218a82f067e0e59ec59048ef7a 100644 (file)
@@ -33,8 +33,8 @@ class ActionPlan < ActiveRecord::Base
   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
@@ -57,6 +57,14 @@ class ActionPlan < ActiveRecord::Base
     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
 
index 61b62974a37111b788a9dab1b80f0b072718994c..60fda96d531dee9bb57940243cba9c7eb1313240 100644 (file)
@@ -1,19 +1,3 @@
-<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">
@@ -46,7 +30,7 @@
     <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>
index c45ce56b77a8ef85bca162acefaf1c7e56b33651..bd9622f7ab3c2fb172cd96761823e7d4fa19ea0a 100644 (file)
@@ -1228,6 +1228,26 @@ div.comment-excerpt {
 }
 
 /* ACTION PLANS */
+#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;
+}
+
+#actionPlans td.over-due {
+  color: #CC0000;
+  font-weight: bold;
+}
 
 div.progress {
   width: 100%;