annotate app/controllers/auto_completes_controller.rb @ 341:b6ec5451fd0d feature_118

Make the project title (h1 in top of page) a link to the project overview (fixes #118). Does not work for the "special" soundsoftware project, which uses image replacement rather than clickable text.
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 31 Mar 2011 11:12:48 +0100
parents 1d32c0a0efbf
children af80e5618e9b
rev   line source
Chris@14 1 class AutoCompletesController < ApplicationController
Chris@14 2 before_filter :find_project
Chris@14 3
Chris@14 4 def issues
Chris@14 5 @issues = []
Chris@14 6 q = params[:q].to_s
Chris@14 7 if q.match(/^\d+$/)
Chris@14 8 @issues << @project.issues.visible.find_by_id(q.to_i)
Chris@14 9 end
Chris@14 10 unless q.blank?
Chris@14 11 @issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
Chris@14 12 end
Chris@14 13 render :layout => false
Chris@14 14 end
Chris@14 15
Chris@14 16 private
Chris@14 17
Chris@14 18 def find_project
Chris@14 19 project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
Chris@14 20 @project = Project.find(project_id)
Chris@14 21 rescue ActiveRecord::RecordNotFound
Chris@14 22 render_404
Chris@14 23 end
Chris@14 24
Chris@14 25 end