From: Simon Brandhof Date: Tue, 4 Dec 2012 13:55:58 +0000 (+0100) Subject: SONAR-3825 improve rendering of measure filter lists X-Git-Tag: 3.4~190 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eb8e412ce6d8c0b38fcda7ee4e077bddf79cb06c;p=sonarqube.git SONAR-3825 improve rendering of measure filter lists --- 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 582bf95e120..8023363dea1 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 @@ -20,8 +20,8 @@ module DashboardHelper include WidgetPropertiesHelper include MetricsHelper - include FiltersHelper include MeasuresHelper + def dashboard_action(action_name, opts={}) if @resource { :action => action_name, :did => @dashboard.id, :id => @resource.id }.merge!(opts) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb deleted file mode 100644 index 1d303e9541a..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb +++ /dev/null @@ -1,89 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2012 SonarSource -# mailto:contact AT sonarsource DOT com -# -# Sonar is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# Sonar is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with Sonar; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 -# -module FiltersHelper - - def goto_page(msg, filter, update_id, override={}) - link_to_remote msg, { - :update => "filter-#{update_id}", - :url => params.merge({:controller => :filters, :action => :list, :id => filter.id, :edit_mode => @edit_mode, :update_id => update_id}.merge(override)), - :after => "$('filter-pages-#{update_id}').hide();$('filter-loading-#{update_id}').show();" - } - end - - def column_title(column, filter, update_id) - if column.sortable? - html=goto_page(h(column.display_name), filter, update_id, {:asc => (!(column.ascending?)).to_s, :sort => column.id}) - else - html=h(column.display_name) - end - if column.variation - html=" #{html}" - end - - if filter.sorted_column==column - html << (column.ascending? ? image_tag("asc12.png") : image_tag("desc12.png")) - end - html - end - - def column_align(column) - (column.on_name? || column.on_key?) ? 'left' : 'right' - end - - def treemap_metrics(filter) - metrics=filter.measure_columns.map { |col| col.metric } - size_metric=(metrics.size>=1 ? metrics[0] : Metric.by_key('ncloc')) - color_metric=nil - if metrics.size>=2 - color_metric=metrics[1] - end - if color_metric.nil? || !color_metric.treemap_color? - color_metric=Metric.by_key('violations_density') - end - [size_metric, color_metric] - end - - def period_names - p1=Property.value('sonar.timemachine.period1', nil, 'previous_analysis') - p2=Property.value('sonar.timemachine.period2', nil, '5') - p3=Property.value('sonar.timemachine.period3', nil, '30') - [period_name(p1), period_name(p2), period_name(p3)] - end - - private - - def period_name(property) - if property=='previous_analysis' - message('delta_since_previous_analysis') - elsif property=='previous_version' - message('delta_since_previous_version') - elsif property =~ /^[\d]+(\.[\d]+){0,1}$/ - # is integer - message('delta_over_x_days', :params => property) - elsif property =~ /\d{4}-\d{2}-\d{2}/ - message('delta_since', :params => property) - elsif !property.blank? - message('delta_since_version', :params => property) - else - nil - end - end - -end 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 6417dbae590..8c757d0ab12 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 @@ -21,9 +21,9 @@ module MeasuresHelper def list_column_html(filter, column) if column.sort? - html = link_to_function(h(column.name), "reloadParameters({asc:'#{(!filter.sort_asc?).to_s}', sort:'#{column.key}'})") + html = link_to_function(h(column.title_label), "reloadParameters({asc:'#{(!filter.sort_asc?).to_s}', sort:'#{column.key}'})", :title => h(column.tooltip)) else - html=h(column.name) + html=h(column.title_label) end if column.period html += "
Period #{column.period}" @@ -31,7 +31,7 @@ module MeasuresHelper if filter.sort_key==column.key html << (filter.sort_asc? ? image_tag("asc12.png") : image_tag("desc12.png")) end - "#{html}" + "#{html}" end def list_cell_html(column, result) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb index c3d680fe5eb..4c121f98ba0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb @@ -196,7 +196,7 @@ class MeasureFilter < ActiveRecord::Base snapshot_ids = rows.map { |row| row.getSnapshotId() if authorized_project_ids.include?(row.getResourceRootId()) }.compact @security_exclusions = (snapshot_ids.size @metric.short_name) + label = Api::Utils.message("measure_filter.short_col.metric.#{@metric.key}", :default => '') + label = Api::Utils.message("metric.#{@metric.key}.name", :default => @metric.short_name) if label=='' else - Api::Utils.message("measure_filter.col.#{@key}", :default => @key) + label = Api::Utils.message("measure_filter.short_col.#{@key}", :default => '') + label = Api::Utils.message("measure_filter.col.#{@key}", :default => @key) if label=='' end + label + end + + def tooltip + @metric.description if @metric end def align @@ -49,10 +56,14 @@ class MeasureFilterDisplayList < MeasureFilterDisplay end end - def css_title + def title_css 'thin' if @metric && @metric.val_type==Metric::VALUE_TYPE_LEVEL end + def row_css + 'nowrap' unless @metric && !@metric.numeric? + end + def sort? !links? end @@ -60,6 +71,7 @@ class MeasureFilterDisplayList < MeasureFilterDisplay def links? @key == 'links' end + end attr_reader :columns diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb index 95a2c98bec1..482efb095f2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb @@ -158,7 +158,7 @@ <%= link_to_favourite(filter.base_result.snapshot.resource) -%> <% end %> <% filter.display.columns.each do |column| %> - + <%= list_cell_html(column, filter.base_result) -%> <% end %> @@ -171,7 +171,7 @@ <%= link_to_favourite(result.snapshot.resource) -%> <% end %> <% filter.display.columns.each do |column| %> - + <%= list_cell_html(column, result) -%> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb index 751826520ff..ea8981befaf 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb @@ -1,6 +1,7 @@ <% if defined? widget %> <%= message('size') -%>: <%= filter.display.size_metric.short_name -%> <% if filter.display.color_metric %> +    <%= message('color') -%>: <%= filter.display.color_metric.short_name -%> <%= render :partial => 'treemap/gradient', :locals => {:metric => filter.display.color_metric} %> <% end %> <% else %> diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 7f984013c09..ea219327ec7 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -2243,6 +2243,7 @@ td.spacer-top { vertical-align: bottom; line-height: 16px; padding: 4px 5px; + vertical-align: bottom; } .table > tbody > tr > td {