Patch #24877 » 02_filter_subtask_from_issues_autocomplete.patch
| app/controllers/auto_completes_controller.rb | ||
|---|---|---|
|
@issues = []
|
||
|
q = (params[:q] || params[:term]).to_s.strip
|
||
|
status = params[:status].to_s.strip
|
||
|
issue = params[:issue].to_i
|
||
|
if q.present?
|
||
|
scope = Issue.cross_project_scope(@project, params[:scope]).visible
|
||
|
scope = scope.open if status == 'o'
|
||
|
scope = scope.joins(:status).where("#{IssueStatus.table_name}.is_closed = 1") if status == 'c'
|
||
|
scope = scope.where("#{Issue.table_name}.id <> ?", issue) if issue
|
||
|
if q.match(/\A#?(\d+)\z/)
|
||
|
@issues << scope.find_by_id($1.to_i)
|
||
|
end
|
||
| app/views/issues/_attributes.html.erb | ||
|---|---|---|
|
<div class="splitcontentright">
|
||
|
<% if @issue.safe_attribute? 'parent_issue_id' %>
|
||
|
<p id="parent_issue"><%= f.text_field :parent_issue_id, :size => 10, :required => @issue.required_attribute?('parent_issue_id') %></p>
|
||
|
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project, :scope => Setting.cross_project_subtasks, :status => @issue.closed? ? 'c' : 'o')}')" %>
|
||
|
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project, :scope => Setting.cross_project_subtasks, :status => @issue.closed? ? 'c' : 'o', :issue => @issue.id)}')" %>
|
||
|
<% end %>
|
||
|
<% if @issue.safe_attribute? 'start_date' %>
|
||
| test/functional/auto_completes_controller_test.rb | ||
|---|---|---|
|
assert_include "closed", response.body
|
||
|
assert_not_include "Issue due today", response.body
|
||
|
end
|
||
|
def test_auto_complete_with_issue_id_should_not_return_that_issue
|
||
|
get :issues, :project_id => 'ecookbook', :q => 'issue', :issue => '12'
|
||
|
assert_response :success
|
||
|
assert_include "issue", response.body
|
||
|
assert_not_include "Bug #12: Closed issue on a locked version", response.body
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- 3
- Next »