diff options
author | David Gageot <david@gageot.net> | 2012-10-01 10:58:42 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-10-01 15:03:10 +0200 |
commit | 57c87a64a0a545ad81f3859b57d4962260ef6ee3 (patch) | |
tree | 6c24b58f8cd7108d04b308f426256b879357219c /sonar-server/src/main/webapp/WEB-INF | |
parent | d6cac6a13b02ae53896a359df85f7ee0e32b5ac1 (diff) | |
download | sonarqube-57c87a64a0a545ad81f3859b57d4962260ef6ee3.tar.gz sonarqube-57c87a64a0a545ad81f3859b57d4962260ef6ee3.zip |
SONAR-3529 Better look. Use field property type
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF')
18 files changed, 57 insertions, 47 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 d6eb4b4345a..3376c8807d2 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 @@ -23,15 +23,23 @@ module SettingsHelper end def property_name(property) - message("property.#{property.key()}.name", :default => property.name()) + message("property.#{property.key}.name", :default => property.name()) end def property_description(property) - message("property.#{property.key()}.description", :default => property.description()) + message("property.#{property.key}.description", :default => property.description) + end + + def field_name(property, field) + message("field.#{property.key}.#{field.key}.name", :default => field.name) + end + + def field_description(property, field) + message("field.#{property.key}.#{field.key}.description", :default => field.description) end def property_help(property) - message("property.#{property.key()}.help", :default => '') + message("property.#{property.key}.help", :default => '') end def property_value(property) @@ -60,6 +68,10 @@ module SettingsHelper end def input_name(property) - "settings[#{h property.key}]" + (property.multi_values ? '[]' : '') + name = "settings[#{h property.key}]" + if property.multi_values + name += '[]' + end + name end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb index ec98d312c9a..e4bec485aaf 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb @@ -157,7 +157,7 @@ class Property < ActiveRecord::Base def validate if java_definition - validation_result=java_definition.validate(text_value) + validation_result = java_definition.validate(text_value) errors.add_to_base(validation_result.getErrorKey()) unless validation_result.isValid() 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 8bc051e7339..5d2e340b5c3 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 @@ -28,7 +28,7 @@ <% value = property_value(property) -%> <% if property.multi_values -%> - <% value.each_with_index do |sub_value, index| -%> + <% value.each do |sub_value| -%> <%= render "settings/multi_value", :property => property, :value => sub_value, :delete_link => true -%> <% end -%> <div class="template" style="display:none;"> @@ -70,7 +70,7 @@ <script> $j('.delete').live('click', function () { - $j(this).parent('.multi_value').remove(); + $j(this).parents('.multi_value').remove(); return false; }); 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 new file mode 100644 index 00000000000..4cafb504ce0 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb @@ -0,0 +1,22 @@ +<div class="multi_value"> + <div class="field"> + <label><%= message('key') %>:</label> + <%= text_field_tag "property_sets[#{property.key}][]", set_key, :size => 50 -%> + <a href="#" class="delete link-action"><%= message('delete') -%></a> + </div> + + <% property.fields.each do |field| -%> + <div class="field"> + <label><%= field_name(property, field) -%>: </label> + + <% value = Property.value("#{property.key}.#{set_key}.#{field.key}", resource_id) if set_key -%> + <%= render "settings/type_#{field.type}", :property => field, :value => value, :name => "#{property.key}[#{field.key}][]", :id => "input_#{h field.key}" -%> + + <% desc=field_description(property, field) -%> + <% unless desc.blank? %> + <p class="note"><%= desc -%></p> + <% end -%> + </div> + <% end -%> + <br/> +</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb index 347811ce841..db82d07cee7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb @@ -1,5 +1,5 @@ <div id="plugins"> - <h1 class="marginbottom10"><%= message(@resource ? 'project_settings.page' : 'settings.page' ) -%></h1> + <h1 class="marginbottom10"><%= message(@resource ? 'project_settings.page' : 'settings.page') -%></h1> <table width="100%"> <tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb index 284a89f39cd..a08cc708b38 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb @@ -1 +1 @@ -<%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value -%> +<%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value, :name => input_name(property), :id => "input_#{h property.key}" -%> 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 b1643852f5c..117cf3b9127 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="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"> +<select name="<%= name -%>" id="<%= id -%>"> <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 9694f05758e..5f8b11660da 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="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file +<input type="text" name="<%= name -%>" value="<%= h value if value -%>" 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 767aa39ad63..fa2b44e9788 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="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey()-%>"/>
\ No newline at end of file +<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id-%>"/>
\ 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 5080da013d1..ea93d74dec8 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 @@ -1,12 +1,12 @@ <% if !value || value.blank? %> - <textarea rows="5" cols="80" class="width100" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"></textarea> + <textarea rows="5" cols="80" class="width100" name="<%= name -%>" id="<%= id -%>"></textarea> <% else license = controller.java_facade.parseLicense(value) date = license.getExpirationDateAsString() %> <div class="width100"> - <textarea rows="6" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>" style="float: left;width: 390px"><%= h value -%></textarea> + <textarea rows="6" name="<%= name -%>" id="<%= id -%>" 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 ac5d599482c..c4329684079 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="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"> +<select name="<%= name -%>" id="<%= id -%>"> <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 5b3a604ca8d..bb7e70b0721 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="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file +<input type="password" name="<%= name -%>" value="<%= h value if value -%>" 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.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb index 5a5928c9730..d7ce63aa0e6 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,4 +1,4 @@ -<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"> +<select name="<%= name -%>" id="<%= id -%>"> <option value=""><%= message('default') -%></option> <% Property.values(property.propertySetKey).reject(&:blank?).each do |set_key| -%> 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 3ebfdfffdf7..d51e73fc377 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 @@ -1,35 +1,11 @@ <% resource_id = @resource.id if @resource -%> <% Property.values(property.key, resource_id).reject(&:blank?).each do |set_key| -%> - <div class="multi_value"> - <%= text_field_tag "property_sets[#{property.key}][]", set_key -%> - <br/> - - <% property.fields.each do |field| -%> - <label><%= field.key -%>: </label><br/> - <%= text_field_tag "#{property.key}[#{field.key}][]", Property.value("#{property.key}.#{set_key}.#{field.key}", resource_id) -%> - <br/> - <% end -%> - - <a href="#" class="delete link-action"><%= message('delete') -%></a> - <br/><br/> - </div> + <%= render 'settings/set_instance', :property => property, :set_key => set_key, :resource_id => resource_id %> <% end -%> <div class="template" style="display:none;"> - <div class="multi_value"> - <%= text_field_tag "property_sets[#{property.key}][]" %> - <br/> - - <% property.fields.each do |field| -%> - <label><%= field.key -%>: </label><br/> - <%= text_field_tag "#{property.key}[#{field.key}][]" -%> - <br/> - <% end -%> - - <a href="#" class="delete link-action"><%= message('delete') -%></a> - <br/><br/> - </div> + <%= render 'settings/set_instance', :property => property, :set_key => nil, :resource_id => resource_id %> </div> <button class="add_value"><%= message('settings.add') -%></button> 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 9694f05758e..5f8b11660da 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="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file +<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/>
\ 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 1e6839f1524..e2ffefee9ec 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="<%= input_name(property) -%>" id="input_<%= h property.key-%>"> +<select name="<%= name -%>" id="<%= id -%>"> <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 e1951b5f5a2..5f8b11660da 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="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= property.key.parameterize -%>"/>
\ No newline at end of file +<input type="text" name="<%= name -%>" value="<%= h value if value -%>" 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 ce59e4a8a07..f552d9c804d 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="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"><%= h value if value -%></textarea>
\ No newline at end of file +<textarea rows="5" cols="80" class="width100" name="<%= name -%>" id="<%= id -%>"><%= h value if value -%></textarea>
\ No newline at end of file |