]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2662 Minor improvements
authorFabrice Bellingard <bellingard@gmail.com>
Fri, 23 Dec 2011 15:09:05 +0000 (16:09 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Fri, 23 Dec 2011 15:36:55 +0000 (16:36 +0100)
- Show closed action plans by default on the admin page
- Sort them by descending dead-line
- Remove "Show closed action plans" from action plan widget
- Remove "More" links on the widgets
- Fix bug for review search on Derby

plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/reviews/_reviews_list.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/reviews/_reviews_list_widget.html.erb

index 68fd5a360103521a61df8db95bdaf89b86753ac7..74305c4dd888a7218921f8b6beb4e0ed2ca4bc19 100644 (file)
@@ -2,8 +2,6 @@
    if has_role?(:user, @project)
      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}"
 %>
   </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 actionPlans" style="display:none" id="<%= table_id -%>">
-    <thead>
-    <tr>
-      <th colspan="3"></th>
-    </tr>
-    </thead>
-    <tbody>
-      <%
-         closed_action_plans.each do |plan|
-      %>
-      <tr>
-        <td class="nowrap"><%= h(plan.name) -%></td>
-        <td class="nowrap small" align="right"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' '  -%></td>
-        <% if plan.progress[:total]==0 %>
-        <td class="noprogress nowrap"><%= message('action_plans.no_reviews_linked_to_action_plan') -%></td>
-        <% else %>
-        <td class="progress">
-            <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%>
-        </td>
-        <% end %>
-      </tr>
-      <% 
-         end 
-      %>
-    </tbody>
-  </table>
-<% end %>
-  
 </div>
 
 <% end %>
index 6976e7ef4e14ccab06f8a7b637d402e63314f4bf..cbb0a088b0b67a0504b333b4ad054327422a8c59 100644 (file)
 </script>
 
 <div class="line-block">
-  <div style="float:right">
-    <a href="<%= url_for url_options.merge({:action => 'index'}) -%>&action_plan_id=<%= first_action_plan.id -%>" id="planned-review-more-link_<%= widget.id -%>">
-      <%= message('widgets.more') -%>
-    </a>
-  </div>
-  
   <h3>
     <%= title -%>
     <select class="small" style="margin-left: 20px" onchange="showActionPlanOpenReviews(this.value);" id="select-action-plan_<%= widget.id -%>">
index 660c8489c4bd22015569566fb38dbd963b5a0703..257277f7a2f20fcc658821eee5e355e0a54698a9 100644 (file)
@@ -478,8 +478,7 @@ action_plans.resolved_reviews_x_percent=Resolved reviews - {0}% ({1} reviews)
 action_plans.open_reviews_x_percent=Open reviews - {0}% ({1} reviews)
 action_plans.reopen=Reopen
 action_plans.close=Close
-action_plans.show_closed_action_plans=Show closed action plans
-action_plans.hide_closed_action_plans=Hide closed action plans
+action_plans.closed_action_plan=Closed action plans
 
 
 #------------------------------------------------------------------------------
@@ -711,8 +710,6 @@ 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
index 6cd365007036fbf16a180e8678aef81b13fd7975..81304123ec03cb1ab0a6604adc9b241f686ffb8a 100644 (file)
@@ -93,7 +93,7 @@ class ActionPlansController < ApplicationController
   
   def load_action_plans
     @open_action_plans = ActionPlan.find(:all, :conditions => ['status=? AND project_id=?', ActionPlan::STATUS_OPEN, @resource.id], :include => 'reviews', :order => 'dead_line ASC')
-    @closed_action_plans = ActionPlan.find(:all, :conditions => ['status=? AND project_id=?', ActionPlan::STATUS_CLOSED, @resource.id], :include => 'reviews', :order => 'dead_line ASC')
+    @closed_action_plans = ActionPlan.find(:all, :conditions => ['status=? AND project_id=?', ActionPlan::STATUS_CLOSED, @resource.id], :include => 'reviews', :order => 'dead_line DESC')
   end
 
 end
index 0abc9e83e569813ad08fe1eec8e96286ff446b7c..e18dc1816e9c4dcc66ca5bb8d76d001e4b6f3387 100644 (file)
@@ -355,9 +355,12 @@ class Review < ActiveRecord::Base
       action_plan_id = options['action_plan_id']
       if action_plan_id
         action_plan = ActionPlan.find action_plan_id.to_i, :include => 'reviews'
-        if action_plan
+        if action_plan && action_plan.reviews.size>0
           conditions << 'id in (:ids)'
           values[:ids]=action_plan.reviews.map { |r| r.id }
+        else
+          # no action plan or action plan is empty => no need to look into the database
+          no_need_for_db_request = true
         end
       elsif options['unplanned']
         conditions << 'id not in (:ids)'
@@ -389,7 +392,9 @@ class Review < ActiveRecord::Base
       sort = 'reviews.updated_at DESC'
     end
 
-    Review.find(:all, :include => ['review_comments', 'project', 'assignee', 'resource', 'user'], :conditions => [conditions.join(' AND '), values], :order => sort, :limit => 200)
+    found_reviews = []
+    found_reviews = Review.find(:all, :include => ['review_comments', 'project', 'assignee', 'resource', 'user'], :conditions => [conditions.join(' AND '), values], :order => sort, :limit => 200) unless no_need_for_db_request
+    found_reviews
   end
 
 
index ed09e344db8376cd069f57e1102e3c3adfaacb53..89814ea7f104f275d1ed960814781cd949421af5 100644 (file)
@@ -40,6 +40,7 @@
             <td id="desc"><%= h(plan.user.name) -%></td>
             <td class="thin nowrap right">
               <%= link_to message('edit'), :action => 'edit', :id => @resource.id, :plan_id => plan.id, :class => 'action' -%>
+              &nbsp;
               <% 
                 close_confirmation_message = {}
                 if plan.open? && plan.has_open_reviews?
@@ -48,6 +49,7 @@
               %>
               <%= link_to message('action_plans.close'), 
                           {:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'}.merge(close_confirmation_message) -%>
+              &nbsp;
               <%= 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>
       
       
       <% unless @closed_action_plans.empty? %>
-      <script type="text/javascript">
-        function displayClosedActionPlans() {
-          var table = $('closedActionPlans');
-          var link = $('showClosedActionPlanLink');
-          if (table.visible()) {
-            table.hide();
-            link.update("<%= message('action_plans.show_closed_action_plans') -%>");
-          } else {
-            table.show();
-            link.update("<%= message('action_plans.hide_closed_action_plans') -%>");
-          }
-        }
-      </script>
-      <div style="margin-top:30px;"><a href="#" onclick="displayClosedActionPlans();" id ="showClosedActionPlanLink">
-        <%= message('action_plans.show_closed_action_plans') -%></a>
-      </div>
-      <table class="width100 data sortable actionPlans" style="display:none" id="closedActionPlans">
+      <br/><br/>
+      <h1><%= message('action_plans.closed_action_plan') -%></h1>
+      
+      <table class="width100 data sortable actionPlans" id="closedActionPlans">
         <thead>
         <tr>
           <th class="thin nowrap"><%= message('action_plans.col.status') -%></th>
             <td class="thin nowrap right">
               <%= link_to message('action_plans.reopen'), 
                           {:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'} -%>
+              &nbsp;
               <%= 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 c94baa77a67f98738d6644dc28e26b307e89b590..ab15c76257d3817661a5e46b8b407aed24edb9cf 100644 (file)
@@ -10,7 +10,8 @@
      to_date = DateTime.now
      search_options['to'] = to_date
    end
-   reviews = Review.search(search_options)
+   found_reviews = Review.search(search_options)
+   reviews = select_authorized(:user, found_reviews, :project)
 
    # table pagination
    page_size = 20
index f367e5d465a25d19376f99ac9da8a4d3a6556d5b..be01dd0f67809432cad0036a1e3031c85331d9b9 100644 (file)
@@ -7,14 +7,7 @@
      end
 %>
 
-<div class="line-block">
-  <div style="float:right">
-    <a href="<%= url_for search_options.merge({:controller => 'project_reviews', :action => 'index'}) -%>">
-      <%= message('widgets.more') -%>
-    </a>
-  </div>
-  <h3><%= title -%></h3>
-</div>
+<h3><%= title -%></h3>
 
 <div id="reviews-widget-<%= widget_id -%>">
   <%= render :partial => 'project/widgets/reviews/reviews_list',