]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3825 add sidebar "filters"
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 28 Nov 2012 16:45:24 +0000 (17:45 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 28 Nov 2012 17:49:11 +0000 (18:49 +0100)
sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/measures/_filters.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb
sonar-server/src/main/webapp/stylesheets/style.css

index bca19f33bed80472e7bc81b6dd4ebf1f011dda47..53fc617c2453ab8700df248dd955b4b9660bd043 100644 (file)
@@ -175,6 +175,12 @@ class MeasuresController < ApplicationController
     render :text => is_favourite.to_s, :status => 200
   end
 
+  # GET /measures/filters
+  def filters
+    verify_ajax_request
+    render :partial => 'measures/filters'
+  end
+
   private
   def find_filter(id)
     filter = MeasureFilter.find(id)
index 0ab7c92f1a932b12a66165033c0627d949a4392c..90b62d1f25ce7c6ad7ae514833bfc4ecf80d1ef1 100644 (file)
       <% end %>
     <% end %>
     <div id="ftlinks">
-      <%= message('layout.powered_by') -%> <a href="http://www.sonarsource.com" target="SonarSource" class="external">SonarSource</a> - Open Source
-      <a href="http://www.sonarsource.org/documentation/license/" target="license" class="external">LGPL</a> - v.<%= sonar_version -%> -
-      <a href="http://sonar-plugins.codehaus.org" class="external" target="plugins"><%= message('layout.plugins') -%></a> -
-      <a href="http://sonar.codehaus.org/documentation" class="external" target="sonar_doc" class="external"><%= message('layout.documentation') -%></a> -
-      <a href="http://sonar.codehaus.org/support/" target="support" class="external"><%= message('layout.ask_a_questions') -%></a>
+      <%= message('layout.powered_by') -%> <a href="http://www.sonarsource.com" target="SonarSource">SonarSource</a> - Open Source
+      <a href="http://www.sonarsource.org/documentation/license/" target="license">LGPL</a> - v.<%= sonar_version -%> -
+      <a href="http://sonar-plugins.codehaus.org" target="plugins"><%= message('layout.plugins') -%></a> -
+      <a href="http://sonar.codehaus.org/documentation" target="sonar_doc"><%= message('layout.documentation') -%></a> -
+      <a href="http://sonar.codehaus.org/support/" target="support"><%= message('layout.ask_a_questions') -%></a>
       <% unless DatabaseVersion.production? %>
         <br/><span class="yellowHighlight" id="evaluation_warning"><%= message('layout.evaluation') -%></span>
       <% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_filters.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_filters.html.erb
new file mode 100644 (file)
index 0000000..ecc200a
--- /dev/null
@@ -0,0 +1,21 @@
+<ul id="system-filters">
+  <%
+    system_filters = Api::Utils.insensitive_sort(MeasureFilter.find(:all, :include => :user, :conditions => ['system=?', true])) { |f| f.name }
+    system_filters.each do |filter| %>
+    <li>
+      <a href="<%= ApplicationController.root_context -%>/measures/filter/<%= filter.id -%>"><%= h filter.name -%></a>
+    </li>
+  <% end %>
+</ul>
+
+<% if logged_in? %>
+  <br/>
+  <ul id="fav-filters">
+    <% current_user.favourited_measure_filters.each do |filter| %>
+      <li>
+        <a href="<%= ApplicationController.root_context -%>/measures/filter/<%= filter.id -%>"><%= h filter.name -%></a>
+      </li>
+    <% end %>
+  </ul>
+  <a href="<%= ApplicationController.root_context -%>/measures/manage" class="link-action">Manage</a>
+<% end %>
index a5b6f5ddd2e1999b1f8362ee0d76968e000fdb28..4549dbbff090a00c1da2c2162cb3ac1ce14a0511 100644 (file)
@@ -16,6 +16,7 @@
               star.removeClass('fav').addClass('notfav');
               star.attr('title', '<%= escape_javascript message('click_to_add_to_favourites') -%>');
             }
+            $j('#filters-sidebar').load(baseUrl + '/measures/filters');
           }
         });
       });
   </script>
 <% end %>
 
-<h2>My Measure Filters</h2>
-<table class="data marginbottom10" id="my-filters">
-  <thead>
-  <tr>
-    <th class="thin"></th>
-    <th><%= message('name') -%></th>
-    <th><%= message('measure_filter.sharing') -%></th>
-    <th class="right"><%= message('operations') -%></th>
-  </tr>
-  </thead>
-  <tbody>
-  <% if current_user.measure_filters.empty? %>
-    <tr class="even">
-      <td colspan="4"><%= message('filters.no_filters') -%></td>
-    </tr>
-  <% else %>
-    <% current_user.measure_filters.each do |filter| %>
-      <tr id="my-<%= filter.name.parameterize -%>" class="<%= cycle('even', 'odd', :name => 'my-filters') -%>">
-        <td>
-          <%= measure_filter_star(filter, @fav_filter_ids.include?(filter.id)) -%>
-        </td>
-        <td>
-          <%= link_to h(filter.name), :action => 'filter', :id => filter.id -%>
-          <% if filter.description %>
-            <div><%= h filter.description -%></div>
-          <% end %>
-        </td>
-        <td>
-          <% if filter.shared %>
-            Shared with all users
-          <% else %>
-            Private
-          <% end %>
-        </td>
-        <td class="thin nowrap right">
-          <a id="edit_<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/edit_form/<%= filter.id -%>" class="link-action open-modal"><%= message('edit') -%></a>
-          &nbsp;
-          <a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
-          &nbsp;
-          <%= link_to_action message('delete'), "#{ApplicationController.root_context}/measures/delete/#{filter.id}",
-                             :class => 'link-action link-red',
-                             :id => "delete_#{filter.name.parameterize}",
-                             :confirm_button => message('delete'),
-                             :confirm_title => 'measure_filter.delete_confirm_title',
-                             :confirm_msg => 'measure_filter.are_you_sure_want_delete_filter_x',
-                             :confirm_msg_params => [filter.name] -%>
-        </td>
+<div>
+  <div class="page-split-left">
+    <ul class="nav-pills" id="nav-pills">
+      <li><a href="<%= ApplicationController.root_context -%>/measures" id="search-pill">Search</a></li>
+      <li class="active"><a href="#" id="filters-pill">Filters</a></li>
+    </ul>
+
+    <div id="filters-sidebar">
+      <%= render :partial => 'measures/filters' -%>
+    </div>
+  </div>
+
+  <div class="page-split-right width100">
+    <h2>My Measure Filters</h2>
+    <table class="data marginbottom10" id="my-filters">
+      <thead>
+      <tr>
+        <th class="thin"></th>
+        <th><%= message('name') -%></th>
+        <th><%= message('measure_filter.sharing') -%></th>
+        <th class="right"><%= message('operations') -%></th>
       </tr>
-    <% end %>
-  <% end %>
-  </tbody>
-</table>
-
-<br/>
-
-<h2>Shared Measure Filters</h2>
-<table class="data" id="shared-filters">
-  <thead>
-  <tr>
-    <th class="thin"></th>
-    <th><%= message('name') -%></th>
-    <th><%= message('shared_by') -%></th>
-    <th class="right"><%= message('operations') -%></th>
-  </tr>
-  </thead>
-  <tbody>
-  <% if @shared_filters.empty? %>
-    <tr class="even">
-      <td colspan="4"><%= message('filters.no_filters') -%></td>
-    </tr>
-  <% else %>
-    <% @shared_filters.each do |filter| %>
-      <tr id="shared-<%= filter.name.parameterize -%>" class="<%= cycle('even', 'odd', :name => 'shared-filters') -%>">
-        <td>
-          <%= measure_filter_star(filter, @fav_filter_ids.include?(filter.id)) -%>
-        </td>
-        <td>
-          <%= link_to h(filter.name), :action => 'filter', :id => filter.id -%>
-          <% if filter.description %>
-            <div><%= h filter.description -%></div>
-          <% end %>
-        </td>
-        <td>
-          <%= filter.user ? h(filter.user.name) : '-' -%>
-        </td>
-        <td class="thin nowrap right">
-          <a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
-        </td>
+      </thead>
+      <tbody>
+      <% if current_user.measure_filters.empty? %>
+        <tr class="even">
+          <td colspan="4"><%= message('filters.no_filters') -%></td>
+        </tr>
+      <% else %>
+        <% current_user.measure_filters.each do |filter| %>
+          <tr id="my-<%= filter.name.parameterize -%>" class="<%= cycle('even', 'odd', :name => 'my-filters') -%>">
+            <td>
+              <%= measure_filter_star(filter, @fav_filter_ids.include?(filter.id)) -%>
+            </td>
+            <td>
+              <%= link_to h(filter.name), :action => 'filter', :id => filter.id -%>
+              <% if filter.description %>
+                <div><%= h filter.description -%></div>
+              <% end %>
+            </td>
+            <td>
+              <% if filter.shared %>
+                Shared with all users
+              <% else %>
+                Private
+              <% end %>
+            </td>
+            <td class="thin nowrap right">
+              <a id="edit_<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/edit_form/<%= filter.id -%>" class="link-action open-modal"><%= message('edit') -%></a>
+              &nbsp;
+              <a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
+              &nbsp;
+              <%= link_to_action message('delete'), "#{ApplicationController.root_context}/measures/delete/#{filter.id}",
+                                 :class => 'link-action link-red',
+                                 :id => "delete_#{filter.name.parameterize}",
+                                 :confirm_button => message('delete'),
+                                 :confirm_title => 'measure_filter.delete_confirm_title',
+                                 :confirm_msg => 'measure_filter.are_you_sure_want_delete_filter_x',
+                                 :confirm_msg_params => [filter.name] -%>
+            </td>
+          </tr>
+        <% end %>
+      <% end %>
+      </tbody>
+    </table>
+
+    <br/>
+
+    <h2>Shared Measure Filters</h2>
+    <table class="data" id="shared-filters">
+      <thead>
+      <tr>
+        <th class="thin"></th>
+        <th><%= message('name') -%></th>
+        <th><%= message('shared_by') -%></th>
+        <th class="right"><%= message('operations') -%></th>
       </tr>
+      </thead>
+      <tbody>
+      <% if @shared_filters.empty? %>
+        <tr class="even">
+          <td colspan="4"><%= message('filters.no_filters') -%></td>
+        </tr>
+      <% else %>
+        <% @shared_filters.each do |filter| %>
+          <tr id="shared-<%= filter.name.parameterize -%>" class="<%= cycle('even', 'odd', :name => 'shared-filters') -%>">
+            <td>
+              <%= measure_filter_star(filter, @fav_filter_ids.include?(filter.id)) -%>
+            </td>
+            <td>
+              <%= link_to h(filter.name), :action => 'filter', :id => filter.id -%>
+              <% if filter.description %>
+                <div><%= h filter.description -%></div>
+              <% end %>
+            </td>
+            <td>
+              <%= filter.user ? h(filter.user.name) : '-' -%>
+            </td>
+            <td class="thin nowrap right">
+              <a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
+            </td>
+          </tr>
+
+        <% end %>
+      <% end %>
+      </tbody>
+    </table>
+
+  </div>
+
+</div>
+
+
+
+
+
+
+
+
+
 
-    <% end %>
-  <% end %>
-  </tbody>
-</table>
index a1f56543664a0aa822e1192e94986e6ab0d45b1c..870e0f8ab9c2966f6ac1b83532e492eaacc9577b 100644 (file)
@@ -1,17 +1,17 @@
 <% content_for :style do %>
   <style type="text/css">
-    #filter-form [type="text"].large-input {
+    #search-form [type="text"].large-input {
       width: 180px;
     }
 
-    #filter-form select.large-input {
+    #search-form select.large-input {
       width: 100%;
       box-sizing: border-box;
       -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;
     }
 
-    #filter-form select option {
+    #search-form select option {
       padding: 1px 10px 1px 4px;
     }
   </style>
@@ -20,7 +20,7 @@
   <script>
     function submitSearch() {
       // remove empty parameters from URL
-      var form = $j("#filter-form");
+      var form = $j("#search-form");
       form.find(':input[value=""]').attr('name', '');
       form.submit();
       return false;
       });
       window.location = url;
     }
+    var filtersLoaded = false;
+    $j(document).ready(function () {
+        $j('#search-pill').on('click', function (e) {
+          $j('#search-pill').parent().addClass('active');
+          $j('#filters-pill').parent().removeClass('active');
+          $j('#search-form').show();
+          $j('#filters').hide();
+        });
+        $j('#filters-pill').on('click', function (e) {
+          $j('#search-pill').parent().removeClass('active');
+          $j('#filters-pill').parent().addClass('active');
+          $j('#search-form').hide();
+          $j('#filters').show();
+          if (!filtersLoaded) {
+            $j('#filters').load(baseUrl + '/measures/filters');
+            filtersLoaded=true;
+          }
+        });
+      }
+    );
   </script>
 <% end %>
 <div id="measure-filters">
   <div class="page-split-left">
-    <form id="filter-form" method="GET" action="<%= ApplicationController.root_context -%>/measures/search">
+    <ul class="nav-pills" id="nav-pills">
+      <li class="active"><a href="#" id="search-pill">Search</a></li>
+      <li><a href="#" id="filters-pill">Filters</a></li>
+    </ul>
+    <div id="filters" style="display:none"><%= image_tag 'loading.gif' -%></div>
+    <form id="search-form" method="GET" action="<%= ApplicationController.root_context -%>/measures/search">
       <% if @filter.id %>
         <input type="hidden" name="id" value="<%= @filter.id -%>">
       <% end %>
         </tbody>
       </table>
     </form>
-
-    <br/>
-    <ul id="system-filters">
-      <% MeasureFilter.find(:all, :select => ['id,name'], :conditions => ['system=?', true]).each do |system_filter| %>
-        <li>
-          <a href="<%= ApplicationController.root_context -%>/measures/filter/<%= system_filter.id -%>"><%= h system_filter.name -%></a>
-        </li>
-      <% end %>
-    </ul>
-
-    <% if logged_in? %>
-      <br/>
-      <ul id="fav-filters">
-        <% current_user.favourited_measure_filters.each do |my_filter| %>
-          <li>
-            <a href="<%= ApplicationController.root_context -%>/measures/filter/<%= my_filter.id -%>"><%= h my_filter.name -%></a>
-          </li>
-        <% end %>
-      </ul>
-      <a href="<%= ApplicationController.root_context -%>/measures/manage" class="link-action">Manage</a>
-    <% end %>
   </div>
 
   <% if @filter.results && @filter.display %>
index b6c02a430f7d48a97f18c6a7ef67db54c82e7dbb..9a8640bc37a08eed3efd19eacff8a9d9ff0a1280 100644 (file)
@@ -1721,33 +1721,6 @@ ul.bullet li {
   border-top: 0;
   padding: 5px;
 }
-
-#time_machine {
-  margin: 10px 0;
-}
-
-#time_machine #selected {
-  background-image: url("../images/timemachine.png");
-  background-repeat: repeat-x;
-  background-position: left;
-  background-color: #9D9D9D;
-  border: 2px solid #ccc;
-  color: #fff;
-}
-
-#time_machine #selected a {
-  border-bottom: 1px dotted #fff;
-}
-
-#time_machine #selected a.nolink {
-  border-bottom: 0;
-}
-
-#time_machine #selector {
-  background-color: #EFEFEF;
-  border: 1px solid #DDD;
-}
-
 .comments {
   color: #777;
   font-size: 12px;
@@ -2007,11 +1980,11 @@ table.without-header {
   border-top: 1px solid #ddd;
 }
 
-.hoverable.selected a, #time_machine #selected h3, #time_machine #selected a {
+.hoverable.selected a {
   color: #fff;
 }
 
-#time_machine td, .gwt-SourcePanel .sources td {
+.gwt-SourcePanel .sources td {
   vertical-align: top;
 }
 
@@ -2293,6 +2266,10 @@ td.spacer-top {
   border-top: 1px solid #DDD;
 }
 
+select:not([multiple]) {
+  padding: 2px 5px;
+}
+
 select.small-width {
   max-width: 120px;
 }
@@ -2301,23 +2278,6 @@ select.medium-width {
   max-width: 175px;
   width: 175px;
 }
-
-.pipe-left {
-  background-image: url('../images/sep12.png');
-  background-position: left center;
-  background-repeat: no-repeat;
-  padding-left: 8px;
-  margin-left: 8px;
-}
-
-.pipe-right {
-  background-image: url('../images/sep12.png');
-  background-position: right center;
-  background-repeat: no-repeat;
-  margin-right: 8px;
-  padding-right: 8px;
-}
-
 /* Dependencies */
 #dependencies {
   padding: 10px;
@@ -2425,4 +2385,39 @@ textarea.width100 {
 
 .property table.data > thead > tr > th {
   vertical-align: top;
+}
+
+.nav-pills:before, .nav-pills:after {
+  content: "";
+  display: table;
+  line-height: 0;
+}
+
+.nav-pills:after {
+  clear: both;
+}
+
+.nav-pills > li {
+  float: left;
+}
+
+.nav-pills > li > a {
+  line-height: 14px;
+  margin-right: 2px;
+  padding-left: 10px;
+  padding-right: 10px;
+  display: block;
+}
+
+.nav-pills > li > a {
+  border-radius: 5px 5px 5px 5px;
+  margin-bottom: 2px;
+  margin-top: 2px;
+  padding-bottom: 6px;
+  padding-top: 6px;
+}
+
+.nav-pills > .active > a, .nav-pills > .active > a:hover {
+  background-color: #4b9fd5;
+  color: #FFFFFF;
 }
\ No newline at end of file