aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-09-29 22:13:39 +0200
committerDavid Gageot <david@gageot.net>2012-10-01 08:46:47 +0200
commite987cb03edd7854599b93beacefd1b0f6b0dda53 (patch)
treebdb381844876516c417b6d4221d5d5fa11bc95b8 /sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
parentfa5b016978a99f32fdcb249e8325aea41d88f9be (diff)
downloadsonarqube-e987cb03edd7854599b93beacefd1b0f6b0dda53.tar.gz
sonarqube-e987cb03edd7854599b93beacefd1b0f6b0dda53.zip
SONAR-3529 Clean code
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
index 255294383cf..696296616d7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
@@ -49,19 +49,15 @@ class SettingsController < ApplicationController
# TODO: Validation
def save_property_sets(resource_id)
params[:property_sets].each do |key, value|
- value = drop_trailing_blank_values(value)
+ set_keys = drop_trailing_blank_values(value)
- # TODO: clear all
- Property.set(key, value.map { |v| v.gsub(',', '%2C') }.join(','), resource_id)
+ Property.with_key_prefix(key + '.').delete_all
+ Property.set(key, to_string(set_keys), resource_id)
- fields = params[key]
-
- fields.each do |field_key, field_values|
+ params[key].each do |field_key, field_values|
field_values.each_with_index do |field_value, index|
- set_key = value[index]
- if set_key
- Property.set(key + "." + set_key + "." + field_key, field_value, resource_id)
- end
+ set_key = set_keys[index]
+ Property.set("#{key}.#{set_key}.#{field_key}", field_value, resource_id) if set_key
end
end
end
@@ -86,6 +82,10 @@ class SettingsController < ApplicationController
array.reverse.drop_while(&:blank?).reverse
end
+ def to_string(set_keys)
+ set_keys.map { |v| v.gsub(',', '%2C') }.join(',')
+ end
+
def load_properties
@category = params[:category] || 'general'
@@ -102,5 +102,4 @@ class SettingsController < ApplicationController
not_found('category') unless @categories.include? @category
end
-
end