diff options
Diffstat (limited to 'sonar-server')
4 files changed, 55 insertions, 22 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index 7e07b0a35b4..533cebab6ef 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -339,14 +339,7 @@ class RulesConfigurationController < ApplicationController def show_select_tags rule = Internal.quality_profiles.findByRule(params[:rule_id].to_i) - tags = [] - Internal.rule_tags.listAllTags().sort.each do |tag| - tags.push({ - :value => tag, - :selected => (rule.systemTags.contains?(tag) || rule.adminTags.contains?(tag)), - :read_only => rule.systemTags.contains?(tag) - }) - end + tags = tag_selection_for_rule(rule) render :partial => 'select_tags', :locals => { :rule => rule, :tags => tags, :profile_id => params[:profile_id] } end @@ -355,6 +348,14 @@ class RulesConfigurationController < ApplicationController render :partial => 'rule_tags', :locals => {:rule => rule} end + def create_tag + Internal.rule_tags.create(params[:new_tag]) + rule = Internal.quality_profiles.findByRule(params[:rule_id].to_i) + tags = tag_selection_for_rule(rule) + + render :partial => 'select_tags_list', :locals => {:tags => tags} + end + private def init_params @@ -396,4 +397,14 @@ class RulesConfigurationController < ApplicationController new_params end + def tag_selection_for_rule(rule) + Internal.rule_tags.listAllTags().sort.collect do |tag| + { + :value => tag, + :selected => (rule.systemTags.contains?(tag) || rule.adminTags.contains?(tag)), + :read_only => rule.systemTags.contains?(tag) + } + end + end + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb index 6ad68ac712a..8422749efee 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb @@ -94,7 +94,9 @@ <% if profiles_administrator? %> <div id="open_rule_tags_<%= rule.id -%>"> - <a class="link-action open-modal" href="<%=ApplicationController.root_context-%>/rules_configuration/show_select_tags?rule_id=<%=rule.id-%>&profile_id=<%= u profile.id %>">Select Tags</a> + <a class="link-action open-modal" + href="<%=ApplicationController.root_context-%>/rules_configuration/show_select_tags?rule_id=<%=rule.id-%>&profile_id=<%= u profile.id %>"> + <%= message('rules_configuration.select_tags') -%></a> </div> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags.html.erb index e58680e8164..6c522e50458 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags.html.erb @@ -1,4 +1,26 @@ <% #locals = rule, tags, profile_id -%> +<div class="modal-head"> + <h2><%= message('rules_configuration.select_tags_for_rule') -%> <%= h rule.name -%></h2> +</div> + +<form onsubmit="$j.ajax({ + url:'<%=ApplicationController.root_context-%>/rules_configuration/create_tag', + success:function(response){ $j('#select-rule-tags').html(response); }, + error:function(response){ $j('#select-tags-error').html(response); }, + data: $j(this).serialize(), + type:'post'}); + return false;" + method="post" + action="<%=ApplicationController.root_context-%>/rules_configuration/create_tag"> + <%= hidden_field_tag :rule_id, rule.id -%> + <fieldset> + <div class="modal-body"> + <%= text_field_tag 'new_tag', '', :size => 20, :maxlength => 20, :placeholder => message('rules_configuration.new_tag') -%> + <%= submit_tag message('rules_configuration.create_tag'), { :id => 'create_tag' } -%> + </div> + </fieldset> +</form> + <form onsubmit="$j.ajax({ url:'<%=ApplicationController.root_context-%>/rules_configuration/select_tags', success:function(response){ closeModalWindow();$j('#rule_tags_<%=rule.id-%>').html(response); }, @@ -11,26 +33,15 @@ <%= hidden_field_tag :rule_id, rule.id -%> <%= hidden_field_tag :profile_id, profile_id -%> <fieldset> - <div class="modal-head"> - <h2>Select Tags for Rule: <%= h rule.name -%></h2><%# TODO i18n?-%> - </div> - <div class="modal-body"> <div class="modal-error" id="select-tags-error"/> <div id="select-rule-tags" style="height: 200px; overflow-y: visible"> - <ul> - <% tags.each do |tag| -%> - <li style="padding: 5px 2px"> - <%= check_box_tag 'tags[]', tag[:value], tag[:selected], :id => 'tags_'+tag[:value], :disabled => tag[:read_only] -%> - <label for="tags_<%= tag[:value] -%>"><%= tag[:value] -%></label> - </li> - <% end -%> - </ul> + <%= render :partial => 'select_tags_list', :locals => { :tags => tags } -%> </div> </div> <div class="modal-foot"> - <%= submit_tag message('Update Tags'), { :id => 'update_tags_' + rule.id.to_s } -%> + <%= submit_tag message('rules_configuration.update_tags'), { :id => 'update_tags_' + rule.id.to_s } -%> <a href="#" onclick="return closeModalWindow()" id="confirm-cancel"><%= h message('cancel') -%></a> </div> </fieldset> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags_list.html.erb new file mode 100644 index 00000000000..acf36a17146 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_select_tags_list.html.erb @@ -0,0 +1,9 @@ +<% #locals = tags -%> +<ul> +<% tags.each do |tag| -%> + <li style="padding: 5px 2px"> + <%= check_box_tag 'tags[]', tag[:value], tag[:selected], :id => 'tags_'+tag[:value], :disabled => tag[:read_only] -%> + <label for="tags_<%= tag[:value] -%>"><%= tag[:value] -%></label> + </li> +<% end -%> +</ul> |