mirror of
				https://github.com/redmine/redmine.git
				synced 2025-10-30 18:06:30 +01:00 
			
		
		
		
	
		
			
	
	
		
			26 lines
		
	
	
		
			665 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			665 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
|  | class AutoCompletesController < ApplicationController | ||
|  |   before_filter :find_project | ||
|  |    | ||
|  |   def issues | ||
|  |     @issues = [] | ||
|  |     q = params[:q].to_s | ||
|  |     if q.match(/^\d+$/) | ||
|  |       @issues << @project.issues.visible.find_by_id(q.to_i) | ||
|  |     end | ||
|  |     unless q.blank? | ||
|  |       @issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10) | ||
|  |     end | ||
|  |     render :layout => false | ||
|  |   end | ||
|  | 
 | ||
|  |   private | ||
|  | 
 | ||
|  |   def find_project | ||
|  |     project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] | ||
|  |     @project = Project.find(project_id) | ||
|  |   rescue ActiveRecord::RecordNotFound | ||
|  |     render_404 | ||
|  |   end | ||
|  | 
 | ||
|  | end |