From af245798693c9bcc3555abbf407e4c647a37b584 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 23 Dec 2010 22:37:33 +0000 Subject: [PATCH] inheritance tree: display the number of overriding rules --- .../webapp/WEB-INF/app/helpers/profiles_helper.rb | 11 +++++++++++ .../src/main/webapp/WEB-INF/app/models/profile.rb | 7 +++++++ .../WEB-INF/app/views/profiles/inheritance.html.erb | 8 +++++--- sonar-server/src/main/webapp/stylesheets/style.css | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb index 2f6a0353a46..bfd0fbcb3c1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb @@ -21,4 +21,15 @@ module ProfilesHelper def languages controller.java_facade.getLanguages() end + + def label_for_rules_count(profile) + label="#{profile.active_rules.count} rules" + + count_overriding=profile.count_overriding_rules + if count_overriding>0 + label += ", incl. #{count_overriding} overriding" + label += image_tag('overrides.png') + end + label + end end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb index 1c32e082704..e992d1558de 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb @@ -104,6 +104,13 @@ class Profile < ActiveRecord::Base !provided? && !default_profile? && children.empty? end + def count_overriding_rules + @count_overriding_rules||= + begin + active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES']) + end + end + def inherited? parent_name.present? end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb index 50c95d98ec0..c97b7fc1dc6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb @@ -8,17 +8,19 @@
<% @profile.ancestors.reverse.each do |parent| %> - <%= parent.name -%> (<%= parent.active_rules.size -%> rules)
+ <%= parent.name -%> + (<%= label_for_rules_count(parent) -%>)
<%= image_tag 'blue-up.png' -%>
<% end %> - <%= @profile.name -%> (<%= @profile.active_rules.size -%> rules)
+ <%= @profile.name -%> (<%= label_for_rules_count(@profile) -%>)
<% if @profile.children.size>0 %> <%= image_tag 'blue-up.png' -%>
<% @profile.children.each_with_index do |child,index| %> <%= ', ' if index>0 -%> - <%= child.name -%> (<%= child.active_rules.size -%> rules) + <%= child.name -%> + (<%= label_for_rules_count(child) -%>) <% end %>
<%= image_tag 'blue-up.png' -%>
... diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index c4ecdee159c..2be561e7ec2 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -274,7 +274,9 @@ code { font-size: 93%; font-weight: normal; } - +.note img { + vertical-align: bottom; +} .crossout { text-decoration: line-through; } -- 2.39.5