summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-10-04 16:25:18 +0200
committerDavid Gageot <david@gageot.net>2012-10-04 16:33:24 +0200
commit92f19cac9cd14ef8301112e560867f624a8af740 (patch)
tree67a2e2fc48e3f31cf946233caf276eccfadc3098 /sonar-server
parent42a4237c3a54bc78b88d3e941ceb9cf6f72494bc (diff)
downloadsonarqube-92f19cac9cd14ef8301112e560867f624a8af740.tar.gz
sonarqube-92f19cac9cd14ef8301112e560867f624a8af740.zip
SONAR-3529 Improve property sets
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb21
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb19
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb2
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css9
12 files changed, 53 insertions, 22 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
index 1b49f23e2e1..11b71dc084c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
@@ -45,7 +45,6 @@ class ResourceController < ApplicationController
if @extension.getId()=='violations'
render_violations()
elsif (@extension.getId()=='coverage')
- puts '-------------------------------------------'
render_coverage()
elsif (@extension.getId()=='source')
render_source()
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 8125a303679..c64c1f025a2 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
@@ -56,13 +56,22 @@ class SettingsController < ApplicationController
def update_property_sets(resource_id)
(params[:property_sets] || []).each do |key, set_keys|
- Property.with_key_prefix(key + '.').with_resource(resource_id).delete_all
- update_property(key, set_keys, resource_id)
+ Property.transaction do
+ # clear
+ Property.with_key_prefix(key + '.').with_resource(resource_id).delete_all
+
+ # set keys
+ update_property(key, set_keys, resource_id)
+ set_keys.each do |set_key|
+ update_property("#{key}.#{set_key}.key", set_key, resource_id)
+ end
- params[key].each do |field_key, field_values|
- field_values.zip(set_keys).each do |field_value, set_key|
- if set_key
- update_property("#{key}.#{set_key}.#{field_key}", field_value, resource_id)
+ # set fields
+ params[key].each do |field_key, field_values|
+ field_values.zip(set_keys).each do |field_value, set_key|
+ if set_key
+ update_property("#{key}.#{set_key}.#{field_key}", field_value, resource_id)
+ end
end
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
index 6e3500af73d..13603e2af35 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
@@ -38,6 +38,10 @@ module SettingsHelper
message("field.#{property.key}.#{field.key}.description", :default => field.description)
end
+ def key_field(property)
+ property.fields.find { |f| f.key == 'key' }
+ end
+
def option_name(property, field, option)
if field
message("option.#{property.key}.#{field.key}.#{option}.name", :default => option)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb
index a510f678c47..25f871da344 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb
@@ -1,13 +1,18 @@
<% errors = [] -%>
+<% key_field = key_field(property) -%>
-<tr class="multi_value <%= 'template' unless set_key -%>" style="<%= 'display:none' unless set_key -%>">
- <td><%= text_field_tag "property_sets[#{property.key}][]", set_key, :size => 50 -%></td>
+<tr class="top multi_value <%= 'template' unless set_key -%>" style="<%= 'display:none' unless set_key -%>">
+ <% if key_field -%>
+ <td><%= render "settings/type_#{key_field.type}", :property => key_field, :field => key_field, :value => set_key, :name => "property_sets[#{property.key}][]", :id => "input_#{h key_field.key}", :size => key_field.indicativeSize -%></td>
+ <% else -%>
+ <%= hidden_field_tag "property_sets[#{property.key}][]", set_key -%>
+ <% end -%>
- <% property.fields.each do |field| -%>
+ <% property.fields.reject { |field| field.key == 'key' }.each do |field| -%>
<% key = "#{property.key}.#{set_key}.#{field.key}" if set_key -%>
<% value = Property.value(key, resource_id) if set_key -%>
- <td><%= render "settings/type_#{field.type}", :property => field, :field => field, :value => value, :name => "#{property.key}[#{field.key}][]", :id => "input_#{h field.key}" -%></td>
+ <td><%= render "settings/type_#{field.type}", :property => field, :field => field, :value => value, :name => "#{property.key}[#{field.key}][]", :id => "input_#{h field.key}", :size => field.indicativeSize -%></td>
<% errors << (render "settings/error", :key => key) if set_key -%>
<% end -%>
@@ -17,10 +22,14 @@
<% unless errors.all?(&:blank?) -%>
<tr>
- <td></td>
+ <% if key_field -%>
+ <td></td>
+ <% end -%>
+
<% errors.each do |error| -%>
<td><%= error -%></td>
<% end -%>
+
<td></td>
</tr>
<% end -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
index 5f8b11660da..80bad336880 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
@@ -1 +1 @@
-<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/> \ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="<%= (defined? size) ? size : 50 -%>" id="<%= id -%>"/> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
index fa2b44e9788..ea7d4d7d8e7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
@@ -1 +1 @@
-<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id-%>"/> \ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="<%= (defined? size) ? size : 50 -%>" id="<%= id-%>"/> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
index bb7e70b0721..919ff05bd61 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
@@ -1 +1 @@
-<input type="password" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/> \ No newline at end of file
+<input type="password" name="<%= name -%>" value="<%= h value if value -%>" size="<%= defined? size ? size : 50-%>" id="<%= id -%>"/> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb
index 243999d2137..9a601b52a04 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb
@@ -3,8 +3,10 @@
<table class="data">
<thead>
<tr>
- <th><%= message('key') -%></th>
- <% property.fields.each do |field| -%>
+ <% if key_field(property) -%>
+ <th><%= message('key') -%></th>
+ <% end -%>
+ <% property.fields.reject { |field| field.key == 'key' }.each do |field| -%>
<th>
<%= field_name(property, field) -%>
<% desc = field_description(property, field) -%>
@@ -22,12 +24,11 @@
<%= render 'settings/set_instance', :property => property, :set_key => set_key, :resource_id => resource_id %>
<% end -%>
<%= render 'settings/set_instance', :property => property, :set_key => nil, :resource_id => resource_id %>
-
</tbody>
<tfoot>
<tr>
- <td>
+ <td colspan="<%= property.fields.size + 1 -%>">
<button class="add_value"><%= message('settings.add') -%></button>
</td>
</tr>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb
index 5f8b11660da..80bad336880 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb
@@ -1 +1 @@
-<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/> \ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="<%= (defined? size) ? size : 50 -%>" id="<%= id -%>"/> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
index 5f8b11660da..80bad336880 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
@@ -1 +1 @@
-<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/> \ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="<%= (defined? size) ? size : 50 -%>" id="<%= id -%>"/> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb
index f552d9c804d..d5722465b93 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb
@@ -1 +1 @@
-<textarea rows="5" cols="80" class="width100" name="<%= name -%>" id="<%= id -%>"><%= h value if value -%></textarea> \ No newline at end of file
+<textarea rows="5" cols="<%= (defined? size) ? size : 80 -%>" class="width100" name="<%= name -%>" id="<%= id -%>"><%= h value if value -%></textarea> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index 819ddc41a8d..7a86b6f5c64 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -2431,3 +2431,12 @@ textarea.width100 {
.coverage td.name {
text-align: right;
}
+
+.property table.data > tbody > tr > td {
+ vertical-align: top;
+}
+
+.property table.data {
+ width: auto;
+ min-width: 600px;
+} \ No newline at end of file