# since version 3.3
# Exemple : /api/resources/search?s=sonar
+ #
+ # -- Optional parameters
+ # 'display_key' is used to return the resource key instead of the resource id. Default is false
+ #
def search
search_text = params[:s]||''
page=(params[:p] ? params[:p].to_i : 1)
page_size=(params[:ps] ? params[:ps].to_i : 10)
+ display_key=params[:display_key]||false
if params[:q]
qualifiers=params[:q].split(',')
elsif params[:qp]
resources_by_qualifier = resources.group_by(&:qualifier)
json = {
:more => false,
- :results => resources_by_qualifier.map { |qualifier, grouped_resources| {:text => message("qualifiers.#{qualifier}"), :children => grouped_resources.map { |r| {:id => r.id, :text => r.name(true)} }} }
+ :results => resources_by_qualifier.map { |qualifier, grouped_resources| {:text => message("qualifiers.#{qualifier}"),
+ :children => grouped_resources.map { |r| {:id => display_key ? r.key : r.id, :text => r.name(true)} }} }
}
else
json = {
:more => (page * page_size)<total,
- :results => resources.map { |resource| {:id => resource.id, :text => resource.name(true)} }
+ :results => resources.map { |resource| {:id => display_key ? resource.key : resource.id, :text => resource.name(true)} }
}
end
else
# * <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>:open</tt> - true if the select-box must be open. Default is false.
+ # * <tt>:display_key</tt> - true if the resource key should be used instead of the resource id. Default is false.
# * <tt>:select2_options</tt> - hash of select2 options
#
def resource_select_tag(name, options={})
ws_url+="qp=#{options[:resource_type_property]}"
end
+ if options[:display_key]
+ ws_url+='&display_key=true'
+ end
+
selected_resource = options[:selected_resource]
if selected_resource
- options[:selected_id]=selected_resource.id
+ options[:selected_id]= options[:display_key] ? "'" + selected_resource.key + "'" : selected_resource.id
options[:selected_text]=selected_resource.name(true)
end
<li class="sidebar-title">
<%= message('issue_filter.new_search') -%>
</li>
+ <li id="criteria-project" class="marginbottom5">
+ <!-- TODO replace by project from issues result API-->
+ <% selected_project = @project if @filter.criteria('componentRoots') %>
+ <%= message 'issue_filter.criteria.project' -%>:
+ <%= resource_select_tag 'componentRoots', :resource_type_property => 'supportsGlobalDashboards', :width => '100%',
+ :selected_resource => selected_project,
+ :display_key => true,
+ :placeholder => message('issue_filter.criteria.project'),
+ :html_id => 'select-project',
+ :allow_clear => true
+ -%>
+ </li>
<li id="criteria-severity" class="marginbottom5">
<%= message 'issue_filter.criteria.severities' -%>:
<%= dropdown_tag 'severities[]', options_for_select(RulesConfigurationController::RULE_PRIORITIES, @filter.criteria('severities')),
</li>
<li>
<%= message 'issue_filter.criteria.assignee' -%>:
- <% selected_user = @filter.issues_result.user(@filter.criteria('assignees')) if @filter.issues_result %>
- <%= user_select_tag('assignees', {:selected_user => selected_user, :width => '100%', :placeholder => message('issue_filter.criteria.assignee'),
+ <% selected_assignee = @filter.issues_result.user(@filter.criteria('assignees')) if @filter.issues_result %>
+ <%= user_select_tag('assignees', {:selected_user => selected_assignee, :width => '100%', :placeholder => message('issue_filter.criteria.assignee'),
:html_id => 'select-assignee', :open => false, :allow_clear => true}) -%>
</li>
+ <li>
+ <%= message 'issue_filter.criteria.reporter' -%>:
+ <% selected_reporter = @filter.issues_result.user(@filter.criteria('reporters')) if @filter.issues_result %>
+ <%= user_select_tag('reporters', {:selected_user => selected_reporter, :width => '100%', :placeholder => message('issue_filter.criteria.reporter'),
+ :html_id => 'select-reporter', :open => false, :allow_clear => true}) -%>
+ </li>
+ <li class="marginbottom5">
+ <%= message('issue_filter.criteria.created_after') -%>:<br>
+ <input type="text" name="createdAfter" value="<%= @filter.criteria['createdAfter'] -%>" size="10" maxlength="10" class="marginbottom5">
+ <br>
+ <%= message 'issue_filter.criteria.created_before' -%>:<br>
+ <input type="text" name="createdBefore" value="<%= @filter.criteria['createdBefore'] -%>" size="10" maxlength="10"><br>
+ <span class="small gray"><%= message 'issue_filter.criteria.date_format' -%></span>
+ </li>
<li>
<input type="submit" name="search" value="<%= message('search_verb') -%>" id="search-button" />
<a href="<%= ApplicationController.root_context -%>/issues" class="link-action"><%= message 'issue_filter.new_search' -%></a>