From: Simon Brandhof Date: Mon, 10 Dec 2012 15:39:58 +0000 (+0100) Subject: SONAR-3825 allow to edit system filters X-Git-Tag: 3.4~72 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e4e22d88f91e3b29069419e297c5eaa3c64e39b2;p=sonarqube.git SONAR-3825 allow to edit system filters --- 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 db90a4b5853..d24cfa46ed7 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 @@ -82,7 +82,7 @@ class MeasureFilter < ActiveRecord::Base # Set the metrics of the result measures to load. Array of Metric or String. def metrics=(array=[]) - @metrics = array.map{|m| m.is_a?(Metric) ? m : Metric.by_key(m)}.compact + @metrics = array.map { |m| m.is_a?(Metric) ? m : Metric.by_key(m) }.compact end # Enable the loading of result links. False by default @@ -282,7 +282,11 @@ class MeasureFilter < ActiveRecord::Base # validate uniqueness of name if id # update existing filter - count = MeasureFilter.count('id', :conditions => ['name=? and user_id=? and id<>?', name, user_id, id]) + if user_id + count = MeasureFilter.count('id', :conditions => ['name=? and user_id=? and id<>?', name, user_id, id]) + else + count = MeasureFilter.count('id', :conditions => ['name=? and user_id is null and id<>?', name, id]) + end else # new filter count = MeasureFilter.count('id', :conditions => ['name=? and user_id=?', name, user_id]) @@ -290,7 +294,11 @@ class MeasureFilter < ActiveRecord::Base errors.add_to_base('Name already exists') if count>0 if shared - count = MeasureFilter.count('id', :conditions => ['name=? and shared=? and (user_id is null or user_id<>?)', name, true, user_id]) + if id + count = MeasureFilter.count('id', :conditions => ['name=? and shared=? and (user_id is null or user_id<>?) and id<>?', name, true, user_id, id]) + else + count = MeasureFilter.count('id', :conditions => ['name=? and shared=? and (user_id is null or user_id<>?)', name, true, user_id]) + end errors.add_to_base('Other users already share filters with the same name') if count>0 elsif system? errors.add_to_base("System filters can't be unshared") diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index a3c9e9da837..967ba3be1f4 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -86,6 +86,10 @@ code { font-size: 85%; } +input[type].small { + +} + small { color: #AAA; font-size: 85%; @@ -213,7 +217,7 @@ button[disabled], .button[disabled], input[type="submit"][disabled], input[type= } /* ------------------- PAGE ------------------- */ -h1 { +h1, .h1 { color: #444; font-size: 16px; }