From c8206fbc12e4dbd72226e6532286cbafe763904f Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 18 Mar 2013 18:02:27 +0100 Subject: [PATCH] SONAR-4117 The '%' character is not displayed in Measure Filters on measures relating to "new_coverage" --- .../WEB-INF/app/helpers/application_helper.rb | 4 +- .../WEB-INF/app/helpers/measures_helper.rb | 2 +- .../WEB-INF/app/models/project_measure.rb | 54 +++++++++---------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index bba7078ee5b..7dd87280043 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -436,6 +436,7 @@ module ApplicationHelper # * color: true|false. Default is true. # * period: integer between 1 and 5. By default the index is defined by the dashboard variation select-box # * style: light|normal|none. Default is normal (parenthesis + bold) + # * variation: true|false. Default is true. # # === Examples # format_variation('ncloc') @@ -455,7 +456,8 @@ module ApplicationHelper return m.format_numeric_value(val) end - formatted_val= m.format_numeric_value(val, :variation => true) + variation = !options[:variation].nil? ? options[:variation] : true + formatted_val= m.format_numeric_value(val, :variation => variation) css_class='' if options[:color]||true css_class='var' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb index 14e18b37495..0d0b3af4d4f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb @@ -38,7 +38,7 @@ module MeasuresHelper if column.metric measure = row.measure(column.metric) if column.period - format_variation(measure, :index => column.period, :style => 'light') + format_variation(measure, :index => column.period, :style => 'light', :variation => false) elsif column.metric.numeric? format_measure(measure) + ' ' + trend_icon(measure, :empty => true) else diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb index 2e67489889d..1b02d493062 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -77,24 +77,24 @@ class ProjectMeasure < ActiveRecord::Base end case metric().val_type - when Metric::VALUE_TYPE_INT - number_with_precision(value(), :precision => 0) - when Metric::VALUE_TYPE_FLOAT - number_with_precision(value(), :precision => 1) - when Metric::VALUE_TYPE_PERCENT - number_to_percentage(value(), {:precision => 1}) - when Metric::VALUE_TYPE_MILLISEC - millisecs_formatted_value( value() ) - when Metric::VALUE_TYPE_BOOLEAN - value() == 1 ? 'Yes' : 'No' - when Metric::VALUE_TYPE_LEVEL - text_value - when Metric::VALUE_TYPE_STRING - text_value - when Metric::VALUE_TYPE_RATING - text_value || value.to_i.to_s - else - value().to_s + when Metric::VALUE_TYPE_INT + number_with_precision(value(), :precision => 0) + when Metric::VALUE_TYPE_FLOAT + number_with_precision(value(), :precision => 1) + when Metric::VALUE_TYPE_PERCENT + number_to_percentage(value(), {:precision => 1}) + when Metric::VALUE_TYPE_MILLISEC + millisecs_formatted_value( value() ) + when Metric::VALUE_TYPE_BOOLEAN + value() == 1 ? 'Yes' : 'No' + when Metric::VALUE_TYPE_LEVEL + text_value + when Metric::VALUE_TYPE_STRING + text_value + when Metric::VALUE_TYPE_RATING + text_value || value.to_i.to_s + else + value().to_s end end @@ -104,20 +104,20 @@ class ProjectMeasure < ActiveRecord::Base end case metric().val_type - when Metric::VALUE_TYPE_INT - number_with_precision(val, :precision => 0) - when Metric::VALUE_TYPE_FLOAT - number_with_precision(val, :precision => 1) - when Metric::VALUE_TYPE_PERCENT + when Metric::VALUE_TYPE_INT + number_with_precision(val, :precision => 0) + when Metric::VALUE_TYPE_FLOAT + number_with_precision(val, :precision => 1) + when Metric::VALUE_TYPE_PERCENT if (options[:variation]==true) number_with_precision(val, :precision => 1) else number_to_percentage(val, {:precision => 1}) end - when Metric::VALUE_TYPE_MILLISEC - millisecs_formatted_value(val) - else - val.to_s + when Metric::VALUE_TYPE_MILLISEC + millisecs_formatted_value(val) + else + val.to_s end end -- 2.39.5