]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3825 allow to unset the root project criteria
authorSimon Brandhof <simon.brandhof@gmail.com>
Sun, 9 Dec 2012 19:31:34 +0000 (20:31 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Sun, 9 Dec 2012 19:31:34 +0000 (20:31 +0100)
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/measures/_sidebar.html.erb

index 7a992b719b9511bc81800d7b2cde00e3c5ceb23e..769eb22b4c072e5b4702db66e8a35289b32c3310 100644 (file)
@@ -610,6 +610,7 @@ module ApplicationHelper
   # * <tt>:resource_type_property</tt> -Filter on resource types on which the property is enabled, for example 'supportsGlobalDashboards'.
   # * <tt>:selected_resource</tt> - the resource that is selected by default.
   # * <tt>:placeholder</tt> - the label to display when nothing is selected
+  # * <tt>:allow_clear</tt> - true if resource can be de-selected. Default is false.
   # * <tt>:select2_options</tt> - hash of select2 options
   #
   def resource_select_tag(name, options={})
@@ -634,6 +635,7 @@ module ApplicationHelper
     min_length = 3 # see limitation in /api/resources/search
     js_options={
       'minimumInputLength' => min_length,
+      'allowClear' => options[:allow_clear]||false,
       'formatNoMatches' => "function(term){return '#{escape_javascript message('select2.noMatches')}'}",
       'formatSearching' => "function(){return '#{escape_javascript message('select2.searching')}'}",
       'formatInputTooShort' => "function(term, minLength){return '#{escape_javascript message('select2.tooShort', :params => [min_length])}'}"
index 120a42295360c9ae306aeae3203cf8259972e158..fde618491139e973d676dd5970e32c39e8956139 100644 (file)
       <%= select_tag 'qualifiers[]', options_for_select(qualifiers, @filter.criteria['qualifiers']||''), :multiple => true, :id => 'select-qualifiers' -%>
     </li>
     <li id="criteria-project" <%= "style='display:none'" unless @filter.base_resource -%>>
-      <%= resource_select_tag 'baseId', :resource_type_property => 'supportsGlobalDashboards', :width => '100%', :selected_resource => @filter.base_resource, :placeholder => message('project'), :html_id => 'select-project' -%>
+      <%= resource_select_tag 'baseId', :resource_type_property => 'supportsGlobalDashboards', :width => '100%',
+                              :selected_resource => @filter.base_resource,
+                              :placeholder => message('project'),
+                              :html_id => 'select-project',
+                              :allow_clear => true
+      -%>
     </li>
     <li id="criteria-lang" <%= "style='display:none'" unless @filter.criteria('languages') -%>>
       <% languages = [['', '']].concat(Api::Utils.languages.map { |lang| [lang.name, lang.key] }) %>
     <% for i in 1..3 %>
       <li id="criteria-metric-<%= i -%>" style="<%= "display: none" if hidden_condition_indexes.include?(i) -%>">
         <%= metric_select_tag "c#{i}_metric", condition_metrics, :allow_empty => true, :selected_key => @filter.criteria("c#{i}_metric"), :width => '100%', :placeholder => 'Metric' -%>
-        <%= select_tag "c#{i}_period", options_for_select([['Value', ''], ['Period 1', '1'], ['Period 2', '2'], ['Period 3', '3']], @filter.criteria("c#{i}_period")) -%>
+        <%= select_tag "c#{i}_period", options_for_select([['Value', ''], [Api::Utils.period_label(1), '1'], [Api::Utils.period_label(2), '2'], [Api::Utils.period_label(3), '3']], @filter.criteria("c#{i}_period")) -%>
         <br>
         <%= select_tag "c#{i}_op", options_for_select([['=', 'eq'], ['<', 'lt'], ['<=', 'lte'], ['>', 'gt'], ['>=', 'gte']], @filter.criteria("c#{i}_op")) -%>
         <input type="text" size="5" name="c<%= i -%>_val" value="<%= h @filter.criteria("c#{i}_val") -%>">