diff options
3 files changed, 22 insertions, 15 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index 9530ab40825..e4c01a4449f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -45,18 +45,23 @@ module DashboardHelper def period_select_option_tags(snapshot, html_class = '') selected=(!params[:period] || params[:period] == '0' ? 'selected' : '') options = "<option #{selected} value='0' class='#{html_class}'/>#{message('time_changes')}...</option>" + period_options = '' (1..5).each { |index| option = period_select_options(snapshot, index, html_class) if option - options += option + period_options += option end } - options + if !period_options.empty? + options += period_options + else + nil + end end def period_select_options(snapshot, index, html_class = '') label = period_label(snapshot, index) - if label + if label && snapshot.period_datetime(index) selected=(params[:period]==index.to_s ? 'selected' : '') "<option value='#{index}' #{selected} class='#{html_class}'>Δ #{label}</option>" else diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb index d9f6ee8c617..e8191011ade 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb @@ -18,15 +18,16 @@ <h4> <%= "Version #{@snapshot.version} - " if @snapshot.version.present? -%><%= l @snapshot.created_at -%> <% 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 -%>"/> - <%= dropdown_tag "period", period_select_option_tags(@snapshot, 'small'), { - :width => '230px', - }, {:id => 'select-comparison', :onchange => 'submit()'} -%> - </form> + <% period_options = period_select_option_tags(@snapshot, 'small') %> + <% if period_options %> + <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 -%>"/> + <%= dropdown_tag "period", period_options, {:width => '230px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%> + </form> + <% end %> <% end %> </h4> </div> <% end %> </div> -<% end %>
\ No newline at end of file +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb index 1a69136f60b..c8c8130e949 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb @@ -9,11 +9,12 @@ <% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %> <% end %> <% if @snapshot.project_snapshot.periods? %> - <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline" class="spacer-left"> - <%= dropdown_tag "period", period_select_option_tags(@snapshot, 'small'), { - :width => '230px', - }, {:id => 'select-comparison', :onchange => 'submit()'} -%> - </form> + <% period_options = period_select_option_tags(@snapshot, 'small') %> + <% if period_options %> + <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline" class="spacer-left"> + <%= dropdown_tag 'period', period_options, {:width => '230px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%> + </form> + <% end %> <% end %> </h4> </div> |