]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4193 Improve modal rule window layout
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 13 Mar 2013 11:32:04 +0000 (12:32 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 13 Mar 2013 11:32:04 +0000 (12:32 +0100)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/javascripts/application.js

index c22e6e18db906612e7eef5c56cc9cd09eea2a021..c823e30bc8ab7c62bbf35c13999e2f6c413be01d 100644 (file)
@@ -1470,6 +1470,7 @@ rules_configuration.removed_since=Removed since
 rules.more_about_rule_on_profile_x=More about this rule on profile "{0}"
 rules.identification=Identification
 rules.parameters=Parameters
+rules.not_found=The rule "{0}" does not exists
 
 
 #------------------------------------------------------------------------------
index 3d3e68506253675c28480968e5110069f0ec5c76..e1b03226c4ddf2d49dd06e2022461de45ff3362e 100644 (file)
@@ -22,14 +22,18 @@ class RulesController < ApplicationController
   SECTION=Navigation::SECTION_CONFIGURATION
   
   def show
-    key=params[:id]
-    if key.to_i==0
-      parts=key.split(':')
-      @rule=Rule.find(:first, :conditions => ['plugin_name=? and plugin_rule_key=?', parts[0], parts[1]])
+    @key=params[:id]
+    if @key.to_i==0
+      parts=@key.split(':')
+      @rule=Rule.first(:conditions => ['plugin_name=? and plugin_rule_key=?', parts[0], parts[1]])
     else
-      @rule=Rule.find(key)
+      @rule=Rule.find(@key)
+    end
+    @page_title=@rule.name if @rule
+
+    if params[:modal] == 'true'
+      render :partial => 'show'
     end
-    @page_title=@rule.name
   end
 
 end
index 081ece9f918716f6e0ffb7e0da2e46471c8c2f69..fca03571b605fa85dfcc099da2c26f455158f764 100644 (file)
@@ -789,6 +789,8 @@ module ApplicationHelper
 
   def process_rule_description(rule)
     description = rule.description
-    description.gsub(/\{toRule (.+):(.+)\}/, "<a class='open-modal' href='#{ApplicationController.root_context}/rules/show/"+ '\1:\2' +"?layout=false'>"+ '\1:\2' +"</a>")
+    description.gsub(
+        /\{toRule (.+):(.+)\}/,
+        "<a class='open-modal rule-modal' href='#{ApplicationController.root_context}/rules/show/"+ '\1:\2' +"?modal=true&layout=false'>" + '\1:\2' +"</a>")
   end
 end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb
new file mode 100644 (file)
index 0000000..40197c2
--- /dev/null
@@ -0,0 +1,40 @@
+<div style="padding:5px;">
+
+  <% if @rule %>
+  <div class="form-head" style="height:40px">
+    <h2>
+      <%= @rule.name %>
+    </h2>
+    <div class="subtitle" style="line-height:0px;">
+      <%= @rule.plugin_name -%> : <%= @rule.plugin_rule_key -%>
+    </div>
+  </div>
+  <% end %>
+
+  <div class="form-body">
+    <% if @rule %>
+      <% if @rule.description.strip.start_with?('<p>') %>
+        <%= process_rule_description @rule %>
+      <% else %>
+        <p><%= process_rule_description @rule %></p>
+      <% end %>
+
+      <% if @rule.note && !@rule.note.text.strip.blank? %>
+        <p><%= @rule.note.html_text -%></p>
+      <% end %>
+    <% else %>
+      <p class="error"><%= message('rules.not_found', :params => @key) %>
+    <% end %>
+  </div>
+
+  <div class="form-foot">
+    <a href="#" onclick="return closeModalWindow()"><%= h message('close') -%></a>
+  </div>
+
+</div>
+
+<script type="text/javascript">
+  $j(document).ready(function () {
+    $j('.rule-modal').modal()
+  });
+</script>
index 15444bd420daf55242243f6cf0511199a4fa188d..7190f0614aeef3f66d0f234d468164ffe5447a05 100644 (file)
@@ -248,10 +248,10 @@ Treemap.prototype.initNodes = function () {
       return this.each(function () {
         var obj = $j(this);
         var $link = obj.bind('click', function () {
-          if ($j('#modal').length) {
-            return; // another window is already opening
+          var $dialog = $j('#modal');
+          if (!$dialog.length) {
+            $dialog = $j('<div id="modal" class="ui-widget-overlay"></div>').appendTo('body');
           }
-          var $dialog = $j('<div id="modal" class="ui-widget-overlay"></div>').appendTo('body');
           var url = $link.attr('modal-url') || $link.attr('href');
           $j.get(url,function (html) {
             $dialog.removeClass('ui-widget-overlay');