diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-04-19 17:50:52 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-04-19 17:51:37 +0200 |
commit | 236ceee8132a8295d9102841359a53ff29b19da0 (patch) | |
tree | c3f5dc7193f3a6fa0c3e5d1b7885a754a55631cb /sonar-server | |
parent | abdafd47033c98ffe399ebc87709f07098b5a4aa (diff) | |
download | sonarqube-236ceee8132a8295d9102841359a53ff29b19da0.tar.gz sonarqube-236ceee8132a8295d9102841359a53ff29b19da0.zip |
SONAR-3159 Properties sub-categories, sort and description
Diffstat (limited to 'sonar-server')
5 files changed, 49 insertions, 9 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb index 29c9210aa01..c199b0e7496 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb @@ -214,8 +214,15 @@ class ApplicationController < ActionController::Base Api::Utils.insensitive_sort(categories) { |category| category_name(category) } end + def by_subcategory_name(category, subcategories) + Api::Utils.insensitive_sort(subcategories) { |subcategory| subcategory_name(category, subcategory) } + end + def category_name(category) message("property.category.#{category}", :default => category) end + def subcategory_name(category, subcategory) + message("property.category.#{category}.#{subcategory}", :default => subcategory) + end end 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 7a11b73a8ae..0c1536ad83a 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 @@ -101,14 +101,17 @@ class SettingsController < ApplicationController def load_properties definitions_per_category = java_facade.propertyDefinitions.getPropertiesByCategory(@resource ? @resource.qualifier : nil) - @categories = definitions_per_category.keys + SPECIAL_CATEGORIES @categories = by_category_name(@categories) default_category = nil default_category = @categories[0] if !@categories.empty? @category = params[:category] || default_category - @definitions = definitions_per_category[@category] || [] + @subcategory = params[:subcategory] || 'default' + @subcategories_per_categories = {} + definitions_per_category.each {|category, definitions_per_subcategories| @subcategories_per_categories.store(category, by_subcategory_name(category, definitions_per_subcategories.keys - ['default'])) } + @definitions = definitions_per_category[@category] || {} + @definitions = @definitions[@subcategory] || [] not_found('category') unless @categories.include? @category 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 3493a7397cf..81452b70ec9 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 @@ -24,6 +24,10 @@ module SettingsHelper message("property.category.#{category}", :default => category) end + def subcategory_name(category, subcategory) + message("property.category.#{category}.#{subcategory}", :default => subcategory) + end + def property_name(property) message("property.#{property.key}.name", :default => property.name) end @@ -52,6 +56,14 @@ module SettingsHelper message("category.#{category}.help", :default => '') end + def category_desc(category) + message("property.category.#{category}.description", :default => '') + end + + def subcategory_desc(category, subcategory) + message("property.category.#{category}.#{subcategory}.description", :default => '') + end + def property_value(property) if property.multi_values? Property.values(property.key, @resource ? @resource.id : nil) @@ -73,8 +85,8 @@ module SettingsHelper property.type end - def by_property_name(properties) - Api::Utils.insensitive_sort(properties) { |property| property_name(property) } + def by_property_index_or_name(properties) + properties.sort_by { |p| [p.index, property_name(p).downcase] } end def input_name(property) 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 f18db1161ff..e1101c8f65a 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 @@ -1,7 +1,7 @@ <% if SettingsController::SPECIAL_CATEGORIES.include?(@category) -%> <%= render 'special', :url => url_for(:controller => "#{@category}_configuration") -%> <% else -%> - <% form_remote_tag :url => {:controller => 'settings', :action => 'update', :category => @category, :resource_id => @resource ? @resource.id : nil}, + <% form_remote_tag :url => {:controller => 'settings', :action => 'update', :category => @category, :subcategory => @subcategory, :resource_id => @resource ? @resource.id : nil}, :method => :post, :before => "$('submit_settings').hide();$('loading_settings').show();", :update => 'properties', @@ -10,11 +10,21 @@ <table class="data marginbottom10"> <thead> <tr> - <th><%= h category_name(@category) -%></th> + <th><%= h category_name(@category) -%><% if @subcategory != 'default' %> - <%= h subcategory_name(@category, @subcategory) -%><% end -%></th> </tr> </thead> <tbody> - <% by_property_name(@definitions).each do |property| -%> + <% unless @subcategory != 'default' || category_desc(@category).blank? -%> + <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>"> + <td class="help"><%= category_desc(@category) -%> </td> + </tr> + <% end -%> + <% unless @subcategory == 'default' || subcategory_desc(@category, @subcategory).blank? -%> + <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>"> + <td class="help"><%= subcategory_desc(@category, @subcategory) -%> </td> + </tr> + <% end -%> + <% by_property_index_or_name(@definitions).each do |property| -%> <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>"> <td style="padding: 10px" id="block_<%= property.key -%>"> <h3> @@ -50,11 +60,12 @@ </tr> <% end -%> - <% unless category_help(@category).blank? -%> + <% unless @subcategory != 'default' || category_help(@category).blank? -%> <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>"> <td class="help"><%= category_help(@category) -%> </td> </tr> <% end -%> + </tbody> </table> <div style="padding-left: 16px;"> 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 ca7f2297df4..a6e6776518f 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 @@ -14,6 +14,13 @@ <% @categories.each do |category| -%> <tr id="select_<%= category -%>" class="select <%= cycle('even', 'odd', :name => 'category') -%> <%= 'selected' if @category==category -%>"> <td><%= link_to category_name(category), :category => category -%></td> + <% if @category==category + (@subcategories_per_categories[category]||[]).each do |subcategory| -%> + <tr id="select_<%= subcategory -%>" class="select <%= cycle('even', 'odd', :name => 'category') -%> <%= 'selected' if @subcategory==subcategory -%>"> + <td> - <%= link_to subcategory_name(category, subcategory), :category => category, :subcategory => subcategory -%></td> + </tr> + <% end + end -%> </tr> <% end -%> </tbody> @@ -28,4 +35,4 @@ </td> </tr> </table> -</div>
\ No newline at end of file +</div> |