# * <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={})
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])}'}"
<%= 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") -%>">