@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}>Δ #{label}</option>"
+ "<option value='#{index}' #{selected} class='#{html_class}'>Δ #{label}</option>"
else
nil
end
<% 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>