diff options
author | David Gageot <david@gageot.net> | 2012-09-24 19:14:20 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-09-24 19:24:13 +0200 |
commit | 082a1b5cf450f5f0837d0d51efe3a4f90c24181b (patch) | |
tree | 6040617bb6152d5b339922e26444ba21cd1796ab /sonar-server | |
parent | dffab878ddf772d36f56b94ee1a739bc3fc1a984 (diff) | |
download | sonarqube-082a1b5cf450f5f0837d0d51efe3a4f90c24181b.tar.gz sonarqube-082a1b5cf450f5f0837d0d51efe3a4f90c24181b.zip |
SONAR-3529 API: ability to define property sets.
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb | 29 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb | 2 |
2 files changed, 27 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb index 61007210470..b7e20fe1a1e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb @@ -17,8 +17,31 @@ # License along with {library}; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # -class PropertySet - def self.findAll(property_set_name) - [property_set_name + '1', property_set_name + '2'] +class PropertySet < ActiveRecord::Base + attr_accessor :name + + def self.columns + @columns ||= []; + end + + def self.column(name, sql_type = nil, default = nil, null = true) + columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) + end + + def self.findAll(set_name) + ActiveSupport::JSON.decode(values_as_json(set_name)).map { |set| PropertySet.new(set) } + end + + def save(validate = true) + validate ? valid? : true + end + + private + + def self.values_as_json(set_name) + json = Property.value('sonar.property_set.' + set_name) + + #json || '[]' + json || '[{"name":"set1"},{"name":"set2"}]' end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb index ad61e35f16b..613c806d581 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb @@ -1,6 +1,6 @@ <select name="<%= input_name(property) -%>" id="input_<%= h property.key -%>"> <option value=""><%= message('default') -%></option> - <% property_set_values(property).each do |option| %> + <% property_set_values(property).map(&:name).each do |option| %> <option value="<%= h option -%>" <%= 'selected' if value && value==option -%>><%= h option -%></option> <% end %> <option value="">New value...</option> |