From 71c3c02b563bc06e72a1666ad2fe26ae7d47c681 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Tue, 12 Oct 2010 09:16:03 +0000 Subject: [PATCH] SONAR-1697 XML default property values are not correctly displayed in the Settings pages --- .../app/controllers/settings_controller.rb | 18 ++++++++++++------ .../app/views/settings/_plugins.html.erb | 5 ++--- 2 files changed, 14 insertions(+), 9 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 9b4126436c7..766eb5135b0 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 @@ -39,16 +39,22 @@ class SettingsController < ApplicationController properties=java_facade.getPluginProperties(plugin) properties.each do |property| value=params[property.key()] - old_value=params['old_' + property.key()] - if (value != old_value) - if value.blank? - Property.clear(property.key(), resource_id) - else - Property.set(property.key(), value, resource_id) + persisted_property = Property.find(:first, :conditions => {:prop_key=> property.key(), :resource_id => resource_id, :user_id => nil}) + + if persisted_property + if value.empty? + Property.delete_all('prop_key' => property.key(), 'resource_id' => resource_id, 'user_id' => nil) + elsif persisted_property.text_value != value.to_s + persisted_property.text_value = value.to_s + persisted_property.save end + elsif !value.blank? + Property.create(:prop_key => property.key(), :text_value => value.to_s, :resource_id => resource_id) end end end + java_facade.reloadConfiguration() + flash[:notice] = 'Parameters updated.' if resource_id redirect_to :controller => 'project', :action => 'settings', :id => resource_id diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb index 5948e312783..f47ce1da745 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb @@ -83,7 +83,6 @@

<%= property.description() %>

<% span_id = "text_" + property.key().gsub('.', '_') %> - <% textfield = text_field_tag property.key(), value, :size => '20' %> <% textfield += link_to_function(image_tag("zoom.png"), "replaceTextField('#{span_id}', '#{property.key()}')", :id => "toggle_text", :class => 'nolink') %> <% textarea = text_area_tag property.key(), value, :size => "100x10" %> @@ -91,9 +90,9 @@ <% unless property.defaultValue().blank? %> <% if project.nil? %> - Default : <%= property.defaultValue() -%> + Default : <%= h property.defaultValue() -%> <% else %> - Default : <%= Property.value(property.key(), nil, property.defaultValue()) -%> + Default : <%= h Property.value(property.key(), nil, property.defaultValue()) -%> <% end %> <% end %>

-- 2.39.5