]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4418 Refactor the bulk change redirection to fix bug when displaying resource...
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 5 Jul 2013 16:33:25 +0000 (18:33 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 5 Jul 2013 16:33:25 +0000 (18:33 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb

index 8e9232a1e39669001089240334b985fdede3c0ee..7d096f9931ae5419907ff63a6a03f241edbd1a0e 100644 (file)
@@ -148,9 +148,9 @@ class DashboardController < ApplicationController
 
     if logged_in?
       if params[:did]
-        @dashboard=Dashboard.find(:first, :conditions => ['id=? AND user_id=?', params[:did].to_i, current_user.id])
+        @dashboard=Dashboard.first(:conditions => ['id=? AND user_id=?', params[:did].to_i, current_user.id])
       elsif params[:name]
-        @dashboard=Dashboard.find(:first, :conditions => ['name=? AND user_id=?', params[:name], current_user.id])
+        @dashboard=Dashboard.first(:conditions => ['name=? AND user_id=?', params[:name], current_user.id])
       elsif params[:id]
         active=ActiveDashboard.user_dashboards(current_user, false).first
       else
@@ -161,9 +161,9 @@ class DashboardController < ApplicationController
     unless active or @dashboard
       # anonymous or not found in user dashboards
       if params[:did]
-        @dashboard=Dashboard.find(:first, :conditions => ['id=? AND shared=?', params[:did].to_i, true])
+        @dashboard=Dashboard.first(:conditions => ['id=? AND shared=?', params[:did].to_i, true])
       elsif params[:name]
-        @dashboard=Dashboard.find(:first, :conditions => ['name=? AND shared=?', params[:name], true])
+        @dashboard=Dashboard.first(:conditions => ['name=? AND shared=?', params[:name], true])
       elsif params[:id]
         active=ActiveDashboard.user_dashboards(nil, false).first
       else
index dc520aaa14053e16e43eadee4453ce7d71756f0e..b30592b268d9fe278879b29a170c28fdbdcb8727 100644 (file)
@@ -144,12 +144,11 @@ class IssuesController < ApplicationController
 
   # GET /issues/bulk_change_form?[&criteria]
   def bulk_change_form
-    params[:from] ||= 'issue_filters'
-    params_for_query = params.clone.merge({'pageSize' => -1})
+    issues_query_params = params.clone.merge({'pageSize' => -1})
     if params[:id]
-      @issue_filter_result = Internal.issues.execute(params[:id].to_i, params_for_query)
+      @issue_filter_result = Internal.issues.execute(params[:id].to_i, issues_query_params)
     else
-      @issue_filter_result = Internal.issues.execute(params_for_query)
+      @issue_filter_result = Internal.issues.execute(issues_query_params)
     end
     render :partial => 'issues/bulk_change_form'
   end
@@ -158,7 +157,7 @@ class IssuesController < ApplicationController
   def bulk_change
     verify_post_request
     Internal.issues.bulkChange(params, params[:comment])
-    render :text => params[:criteria_params], :status => 200
+    render :text => params[:issues_query_params], :status => 200
   end
 
 
index e125579a9e4064f7f5ed3874b44c0fd7b6fa4363..097babb7f5293220c8ec91934fb42c5d6add3527 100644 (file)
     anchor = stripped_url[1];
   }
 
+  // refresh page after issues bulk change
+  function onBulkIssues(issues_query_params, component_key){
+    window.location.reload();
+  }
+
   openAccordionItem('<%= url_for(params.merge({:controller => 'resource', :action => :index, :id => @file.id, :display_title => 'false', :popup => 'false'})) -%>', this, false)
       .done(function () {
         if (anchor != null) {
index 41ce9d5d988f94a0225fe02ccc11458aed3e4415..f076a1c8d589b66e61e233745be2b88ca109871e 100644 (file)
     openAccordionItem(url, this);
     return false;
   }
+
+  // refresh page after issues bulk change
+  function onBulkIssues(issues_query_params, component_key){
+    d(component_key);
+    closeModalWindow();
+  }
 </script>
index 8dafa130e3986c07dee5d5e18312d91951f16d16..43d066db14fcafe17fe4f343bd58bfe99a573ed5 100644 (file)
@@ -24,7 +24,7 @@
 %>
 <form id="bulk-change-form" method="post" action="<%= ApplicationController.root_context -%>/issues/bulk_change">
   <input type="hidden" name="issues" value="<%= issues.map { |issue| issue.key() }.join(',') -%>">
-  <input type="hidden" name="criteria_params" value="<%= params.to_query -%>">
+  <input type="hidden" name="issues_query_params" value="<%= params.to_query -%>">
   <input type="hidden" name="actions[]" id="bulk-change-transition-action">
   <fieldset>
     <div class="modal-head">
            unless plans.empty?
              first_plan = plans[0]
              options = plans.map { |plan|
-               if plan.deadLine
-                 label = "#{h plan.name} (#{format_date(plan.deadLine)})"
-               else
-                 label = h plan.name
-               end
+               label = plan.deadLine ? "#{h plan.name} (#{format_date(plan.deadLine)})" : h(plan.name)
                [label, plan.key]
              }
              options.unshift([escape_javascript(message('issue.unplan.submit')), ''])
 <script>
   $j("#bulk-change-form").modalForm({
     success: function (data) {
-      <% if params[:from] == 'issue_filters' %>
-        window.location = baseUrl + '/issues/search?' + data;
-      <% elsif params[:from] == 'drilldown' %>
-        d('<%= component_key %>');
-        closeModalWindow();
-      <% else %>
-        alert('Unknown origin : <%= params[:from] %>');
-      <% end %>
+      onBulkIssues(data, '<%= component_key %>');
     },
     error: function (xhr, textStatus, errorThrown) {
       $j('#bulk-change-loading-image').addClass("hidden");
index 0c75a11caa523fece85a9631b5ee0090adb526e9..dd06fe00f3cdef14f972c4b8f7660cc36107e0aa 100644 (file)
       <%= render :partial => 'list' -%>
     </div>
   </div>
-</div>
\ No newline at end of file
+</div>
+
+<script type="text/javascript">
+  function onBulkIssues(issues_query_params, component_key){
+    window.location = baseUrl + '/issues/search?' + issues_query_params;
+  }
+</script>
\ No newline at end of file
index a81e243c1bbf447b947c16a2b05b8a408fc9a1ff..cacbdfd7fbaf370a8d1c3ceac8f82fdfdf15b302 100644 (file)
@@ -24,7 +24,7 @@
       <% first=true %>
       <% if logged_in? && @display_issues %>
         <li class="<%= 'first' if first -%>">
-          <a href="<%= url_for @issues_params.merge({:controller => 'issues', :action => 'bulk_change_form', :from => 'drilldown'}) -%>"
+          <a href="<%= url_for @issues_params.merge({:controller => 'issues', :action => 'bulk_change_form'}) -%>"
              class="bulk-change-link open-modal"><%= message('bulk_change') -%></a>
         </li>
       <% first=false
@@ -57,5 +57,4 @@
     </ul>
   </div>
 
-
 <%  end %>