summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-04-27 04:10:33 +0000
committerGo MAEDA <maeda@farend.jp>2023-04-27 04:10:33 +0000
commitccf8e7d2998f40e4673e88fa98d0c6bc89306800 (patch)
tree8506d4b79a56cd244d949e307cdfa3f95853173e /app
parent135606bcf5d17bc5050893edc7243186374ba4ee (diff)
downloadredmine-ccf8e7d2998f40e4673e88fa98d0c6bc89306800.tar.gz
redmine-ccf8e7d2998f40e4673e88fa98d0c6bc89306800.zip
Add a button to apply issues filter to search results (#38481).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@22212 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/search_helper.rb46
-rw-r--r--app/views/search/index.html.erb5
2 files changed, 51 insertions, 0 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index d55cc14aa..a37d75b2d 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -69,4 +69,50 @@ module SearchHelper
links.map {|link| content_tag('li', link)}.join(' ').html_safe +
'</ul>'.html_safe) unless links.empty?
end
+
+ def issues_filter_path(question, options)
+ projects_scope = options[:projects_scope]
+ titles_only = options[:titles_only]
+ all_words = options[:all_words]
+ open_issues = options[:open_issues]
+
+ field_to_search = titles_only ? 'subject' : 'any_searchable'
+ params = {
+ :set_filter => 1,
+ :f => ['status_id', field_to_search],
+ :op => {
+ 'status_id' => open_issues ? 'o' : '*',
+ field_to_search => all_words ? '~' : '*~'
+ },
+ :v => {field_to_search => [question]},
+ :sort => 'updated_on:desc'
+ }
+
+ case projects_scope
+ when 'all'
+ # nothing to do
+ when 'my_projects'
+ params[:f] << 'project_id'
+ params[:op]['project_id'] = '='
+ params[:v]['project_id'] = ['mine']
+ when 'bookmarks'
+ params[:f] << 'project_id'
+ params[:op]['project_id'] = '='
+ params[:v]['project_id'] = ['bookmarks']
+ when 'subprojects'
+ params[:f] << 'subproject_id'
+ params[:op]['subproject_id'] = '*'
+ params[:project_id] = @project.id
+ else
+ if @project
+ # current project only
+ params[:f] << 'subproject_id'
+ params[:op]['subproject_id'] = '!*'
+ params[:project_id] = @project.id
+ end
+ # else all projects
+ end
+
+ issues_path(params)
+ end
end
diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb
index caaa3f35c..5902051ba 100644
--- a/app/views/search/index.html.erb
+++ b/app/views/search/index.html.erb
@@ -46,6 +46,11 @@
<%= render_results_by_type(@result_count_by_type) unless @scope.size == 1 %>
</div>
<h3><%= l(:label_result_plural) %> (<%= @result_count %>)</h3>
+ <% if @result_count_by_type['issues'].to_i > 0 && @search_attachments == '0' %>
+ <p class="buttons">
+ <%= link_to l(:button_apply_issues_filter), issues_filter_path(@question, projects_scope: params[:scope], all_words: @all_words, titles_only: @titles_only, open_issues: @open_issues), :class => 'icon icon-list' %>
+ </p>
+ <% end %>
<dl id="search-results">
<% @results.each do |e| %>
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %>">