diff options
author | David Gageot <david@gageot.net> | 2012-09-24 18:45:21 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-09-24 18:46:23 +0200 |
commit | dffab878ddf772d36f56b94ee1a739bc3fc1a984 (patch) | |
tree | de90d3509137ca1956e8f124b4c45aac2ea44c5e /sonar-server/src | |
parent | 0b846718dbf09e45d7b07b530d7e92f77ca15822 (diff) | |
download | sonarqube-dffab878ddf772d36f56b94ee1a739bc3fc1a984.tar.gz sonarqube-dffab878ddf772d36f56b94ee1a739bc3fc1a984.zip |
SONAR-3529 API: ability to define property sets.
Diffstat (limited to 'sonar-server/src')
14 files changed, 52 insertions, 14 deletions
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 fe7ab2ea4ee..d64fd1d3744 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 @@ -53,4 +53,12 @@ module SettingsHelper def by_name(categories) categories.sort_by { |category| category_name(category) } end + + def input_name(property) + h(property.key) + (property.multi_values ? '[]' : '') + end + + def property_set_values(property) + PropertySet.findAll(property.property_set_name); + end end 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 new file mode 100644 index 00000000000..61007210470 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb @@ -0,0 +1,24 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2012 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# 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'] + end +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb index cb3ee1a3b31..ed62ce8d565 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb @@ -29,15 +29,15 @@ <% value = property_value(property) -%> <% if property.multi_values -%> <% value.each do |sub_value| -%> - <%= render "settings/multi_value", :property => property, :value => sub_value -%> + <%= render "settings/multi_value", :property => property, :value => sub_value, :multi => true -%> <% end -%> <div class="template" style="display:none;"> - <%= render "settings/multi_value", :property => property, :value => nil -%> + <%= render "settings/multi_value", :property => property, :value => nil, :multi => true -%> </div> <button class="add_value"><%= message('settings.add') -%></button> <br/> <% else -%> - <%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value -%> + <%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value, :multi => false -%> <% end -%> <% p = @updated_properties[property.key] if @updated_properties -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb index 9271bbd0c92..b1643852f5c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb @@ -1,4 +1,4 @@ -<select name="<%= h property.getKey() -%>" id="input_<%= h property.getKey() -%>"> +<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"> <option value="" <%= 'selected' if value.blank? -%>><%= message('default') -%></option> <option value="true" <%= 'selected' if value=='true' -%>><%= message('true') -%></option> <option value="false" <%= 'selected' if value=='false' -%>><%= message('false') -%></option> 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 163677b4478..9694f05758e 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="<%= h property.getKey() -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file +<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ 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 5603dfe4a75..767aa39ad63 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="<%= h property.getKey() -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey()-%>"/>
\ No newline at end of file +<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey()-%>"/>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_LICENSE.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_LICENSE.html.erb index 69996fa4419..566f2c37959 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_LICENSE.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_LICENSE.html.erb @@ -6,7 +6,7 @@ date = license.getExpirationDateAsString() %> <div class="width100"> - <textarea rows="6" name="<%= h property.getKey() -%>" id="input_<%= h property.getKey() -%>" style="float: left;width: 390px"><%= h value -%></textarea> + <textarea rows="6" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>" style="float: left;width: 390px"><%= h value -%></textarea> <div style="margin-left: 400px"> <table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb index 45ed790ecf6..ac5d599482c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb @@ -1,4 +1,4 @@ -<select name="<%= h property.getKey() -%>" id="input_<%= h property.getKey() -%>"> +<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"> <option value=""><%= message('default') -%></option> <% metrics_per_domain={} 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 e8b70971e02..5b3a604ca8d 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="<%= h property.getKey() -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file +<input type="password" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file 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 a27d0b0dc2c..ad61e35f16b 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 +1,7 @@ -NOT IMPLEMENTED YET
\ No newline at end of file +<select name="<%= input_name(property) -%>" id="input_<%= h property.key -%>"> + <option value=""><%= message('default') -%></option> + <% property_set_values(property).each do |option| %> + <option value="<%= h option -%>" <%= 'selected' if value && value==option -%>><%= h option -%></option> + <% end %> + <option value="">New value...</option> +</select> 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 b4c3b451f4d..b5e2126fc19 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,2 +1,2 @@ -<input type="text" name="<%= h property.getKey() -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/> +<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/> <%= link_to_function(image_tag('zoom.png'), "enlargeTextInput('#{property.getKey()}')", :class => 'nolink') -%>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_SINGLE_SELECT_LIST.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_SINGLE_SELECT_LIST.html.erb index ac0e0d3d867..1e6839f1524 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_SINGLE_SELECT_LIST.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_SINGLE_SELECT_LIST.html.erb @@ -1,4 +1,4 @@ -<select name="<%= h property.getKey() -%>" id="input_<%= h property.key-%>"> +<select name="<%= input_name(property) -%>" id="input_<%= h property.key-%>"> <option value=""><%= message('default') -%></option> <% property.options.each do |option| %> <option value="<%= h option -%>" <%= 'selected' if value && value==option -%>><%= h option -%></option> 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 07d91a2313e..ee1ec69bd15 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,4 +1,4 @@ -<input type="text" name="<%= h property.key -%>[]" value="<%= h value if value -%>" size="50" id="input_<%= property.key.parameterize -%>"/> +<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= property.key.parameterize -%>"/> <% unless property.multi_values -%> <%= link_to_function(image_tag('zoom.png'), "enlargeTextInput('input_#{property.key.parameterize}')", :class => 'nolink') -%> <% end -%> 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 dfefb03af9f..ce59e4a8a07 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="<%= h property.getKey() -%>" id="input_<%= h property.getKey() -%>"><%= h value if value -%></textarea>
\ No newline at end of file +<textarea rows="5" cols="80" class="width100" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"><%= h value if value -%></textarea>
\ No newline at end of file |