]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2662 Improve the action plan widget
authorFabrice Bellingard <bellingard@gmail.com>
Tue, 20 Dec 2011 16:53:11 +0000 (17:53 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Tue, 20 Dec 2011 16:53:11 +0000 (17:53 +0100)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties

index e3788735a8d723086d62b9ba50ff61be5720be8f..e2041c65f75750aa086ef57a7f7f5398ab3fceda 100644 (file)
@@ -1,25 +1,31 @@
 <%
    if has_role?(:user, @project)
-     action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_OPEN, @project.id], 
-                                          :include => 'reviews', :order => 'dead_line ASC')
+     open_action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_OPEN, @project.id], 
+                                         :include => 'reviews', :order => 'dead_line ASC')
+     closed_action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_CLOSED, @project.id], 
+                                         :include => 'reviews', :order => 'dead_line ASC')
      
      div_id = "action-plan-widget-#{widget.id.to_s}"
 %>
 
 <div class="line-block">
+  <% if has_role?(:admin, @project) %>
   <div style="float:right">
     <a href="<%= url_for :controller => 'action_plans', :action => 'index', :id => @project.id -%>">
       <%= message('widgets.more') -%>
     </a>
   </div>
+  <% end %>
+  
   <h3><%= message('widget.action_plans.title') -%></h3>
 </div>
 
-<% if action_plans.size ==0 %>
-  <span class="empty_widget"><%= message('widget.action_plans.no_action_plan') -%></span>
-<% else %>
 
 <div id="<%= div_id -%>">
+
+<% if open_action_plans.size ==0 %>
+  <span class="empty_widget"><%= message('widget.action_plans.no_action_plan') -%></span>
+<% else %>
   <table class="width100 data actionPlans">
     <thead>
     <tr>
     </thead>
     <tbody>
       <%
-         action_plans.each do |plan|
+         open_action_plans.each do |plan|
       %>
       <tr class="<%= cycle 'even', 'odd', :name => (div_id) -%>">
         <td class="thin nowrap"><%= h(plan.name) -%></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>
+        <td class="thin nowrap <%= 'over-due' if plan.over_due? -%>" align="right"><%= 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>
+        <% else %>
+        <td class="progress thin">
+            <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%>
+        </td>
+        <% end %>
+      </tr>
+      <% 
+         end 
+      %>
+    </tbody>
+  </table>
+<% end %>
+  
+<% 
+  unless closed_action_plans.size ==0 
+    table_id = "closed-action-plan-table-#{widget.id.to_s}"
+    link_id = "closed-action-plan-link-#{widget.id.to_s}"
+%>
+  <script type="text/javascript">
+    function displayClosedActionPlans() {
+      var table = $('<%= table_id -%>');
+      var link = $('<%= link_id -%>');
+      if (table.visible()) {
+        table.hide();
+        link.update("<%= message('widget.action_plans.show_closed_action_plans') -%>");
+      } else {
+        table.show();
+        link.update("<%= message('widget.action_plans.hide_closed_action_plans') -%>");
+      }
+    }
+  </script>
+  <div style="margin-top:10px; font-size:93%"><a href="#" onclick="displayClosedActionPlans();" id ="<%= link_id -%>"><%= message('widget.action_plans.show_closed_action_plans') -%></a></div>
+  <table class="width100 data actionPlans" style="display:none" id="<%= table_id -%>">
+    <thead>
+    <tr>
+      <th colspan="3"></th>
+    </tr>
+    </thead>
+    <tbody>
+      <%
+         closed_action_plans.each do |plan|
+      %>
+      <tr class="<%= cycle 'even', 'odd', :name => (div_id+'closed') -%>">
+        <td class="thin nowrap"><%= h(plan.name) -%></td>
+        <td class="thin nowrap" align="right"><%= 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>
         <% else %>
@@ -46,8 +99,8 @@
       %>
     </tbody>
   </table>
-</div>
-
 <% end %>
+  
+</div>
 
 <% end %>
index 7447f77ef66dd3a3d84a6cf7a59faf666a8a601b..aba492ff7fe5b3d600bc2b1a995f17502de4fccd 100644 (file)
@@ -663,6 +663,8 @@ widget.action_plans.name=Action plans
 widget.action_plans.description=Shows all the open action plans of the project
 widget.action_plans.title=Open action plans
 widget.action_plans.no_action_plan=No action plan
+widget.action_plans.show_closed_action_plans=Show closed action plans
+widget.action_plans.hide_closed_action_plans=Hide closed action plans
 
 widget.planned_reviews.name=Planned reviews
 widget.planned_reviews.description=Shows all the planned reviews of the project, gathered by action plan