kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
|
# ChiliProject is a project management system.
|
||
14 years ago
|
#
|
||
14 years ago
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
||
14 years ago
|
#
|
||
14 years ago
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
14 years ago
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
12 years ago
|
class Issues::AutoCompletesController < ApplicationController
|
||
14 years ago
|
before_filter :find_project
|
||
14 years ago
|
|
||
14 years ago
|
def issues
|
||
|
@issues = []
|
||
|
q = params[:q].to_s
|
||
14 years ago
|
|
||
|
if q.present?
|
||
|
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
||
|
|
||
|
@issues |= query.visible.find_all_by_id(q.to_i) if q =~ /^\d+$/
|
||
|
|
||
|
@issues |= query.visible.find(:all,
|
||
14 years ago
|
:limit => 10,
|
||
|
:order => "#{Issue.table_name}.id ASC",
|
||
|
:conditions => ["LOWER(#{Issue.table_name}.subject) LIKE :q OR CAST(#{Issue.table_name}.id AS CHAR(13)) LIKE :q", {:q => "%#{q.downcase}%" }])
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
14 years ago
|
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
|