]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4184 Use dropdown_tag component on dashboard period select box
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 19 Mar 2013 14:42:29 +0000 (15:42 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 19 Mar 2013 14:42:29 +0000 (15:42 +0100)
sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb

index 169157424c71369a8280f111558ba84be6f07bd5..023af0842081bbda39901dda36d2231e6e29ee92 100644 (file)
@@ -42,11 +42,23 @@ module DashboardHelper
     @snapshot.measure(metric_key)
   end
 
-  def period_select_options(snapshot, index)
+  def period_select_option_tags(snapshot, html_class = '')
+    options = ""
+    options = '<option selected="selected" value=""/>' unless params[:period]
+    (1..5).each { |index|
+      option = period_select_options(snapshot, index, html_class)
+      if option
+        options += option
+      end
+    }
+    options
+  end
+
+  def period_select_options(snapshot, index, html_class = '')
     label=snapshot.period_label(index)
     if label
       selected=(params[:period]==index.to_s ? 'selected' : '')
-      "<option value='#{index}' #{selected}>&Delta; #{label}</option>"
+      "<option value='#{index}' #{selected} class='#{html_class}'>&Delta; #{label}</option>"
     else
       nil
     end
index 073c707a3aae076a975e7bcd21dc97c7f158c011..ac410e4ba6b36262bbcf829568f054390f1cf398 100644 (file)
         <% if @snapshot.project_snapshot.periods? %>
           <form method="GET" action="<%= url_for :controller => :dashboard, :action => :index, :id => @resource.id -%>" style="display: inline" class="spacer-left">
             <input type="hidden" name="did" value="<%= @dashboard.id -%>"/>
-            <select id="select-comparison" name="period" onchange="submit()" class="small">
-              <option value=""><%= message('time_changes') -%>...</option>
-              <%= period_select_options(@snapshot, 1) -%>
-              <%= period_select_options(@snapshot, 2) -%>
-              <%= period_select_options(@snapshot, 3) -%>
-              <%= period_select_options(@snapshot, 4) -%>
-              <%= period_select_options(@snapshot, 5) -%>
-            </select>
+            <%= dropdown_tag "period", period_select_option_tags(@snapshot, 'small'), {
+                :width => '200px',
+                :placeholder => message('time_changes') + '...'
+            }, {:id => 'select-comparison', :onchange => 'submit()'} -%>
           </form>
         <% end %>
       </h4>