diff options
author | Go MAEDA <maeda@farend.jp> | 2019-09-11 06:39:00 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-09-11 06:39:00 +0000 |
commit | 3ba5e04f5ed4c0c88444dd076287b5256ffbfbf6 (patch) | |
tree | d5ffbcba7d56d5fb6587e4759cbbfd72c90bd931 /app/controllers/auto_completes_controller.rb | |
parent | dc657cb2c00da0bf3edaa9be4020ab05c0472b55 (diff) | |
download | redmine-3ba5e04f5ed4c0c88444dd076287b5256ffbfbf6.tar.gz redmine-3ba5e04f5ed4c0c88444dd076287b5256ffbfbf6.zip |
Issue auto complete should return last 10 issues (#31994).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@18449 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/auto_completes_controller.rb')
-rw-r--r-- | app/controllers/auto_completes_controller.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/auto_completes_controller.rb index f6a1414ad..e83374c9b 100644 --- a/app/controllers/auto_completes_controller.rb +++ b/app/controllers/auto_completes_controller.rb @@ -25,20 +25,18 @@ class AutoCompletesController < ApplicationController q = (params[:q] || params[:term]).to_s.strip status = params[:status].to_s issue_id = params[:issue_id].to_s + + scope = Issue.cross_project_scope(@project, params[:scope]).visible + scope = scope.open(status == 'o') if status.present? + scope = scope.where.not(:id => issue_id.to_i) if issue_id.present? if q.present? - scope = Issue.cross_project_scope(@project, params[:scope]).visible - if status.present? - scope = scope.open(status == 'o') - end - if issue_id.present? - scope = scope.where.not(:id => issue_id.to_i) - end if q.match(/\A#?(\d+)\z/) issues << scope.find_by_id($1.to_i) end - issues += scope.like(q).order(:id => :desc).limit(10).to_a issues.compact! + else + issues += scope.order(:id => :desc).limit(10).to_a end render :json => format_issues_json(issues) |