Add ability to Search issues
This commit is contained in:
parent
86021a7dc3
commit
5b284f6adf
7 changed files with 61 additions and 11 deletions
|
@ -78,6 +78,13 @@ class IssuesController < ApplicationController
|
|||
render :nothing => true
|
||||
end
|
||||
|
||||
def search
|
||||
@project = Project.find(params['project'])
|
||||
@issues = @project.issues.where("title LIKE ? OR content LIKE ?", "%#{params['terms']}%", "%#{params['terms']}%")
|
||||
|
||||
render :partial => 'issues'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def issue
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
%div
|
||||
- if can? current_user, :write_issue, @project
|
||||
.left= link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm"
|
||||
.left
|
||||
= form_tag search_project_issues_path(@project), :method => :get, :remote => true do
|
||||
= search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' }
|
||||
= link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm"
|
||||
|
||||
.right
|
||||
= form_tag project_issues_path(@project), :method => :get do
|
||||
.span-2
|
||||
|
@ -20,6 +24,18 @@
|
|||
#issues-table-holder= render "issues"
|
||||
%br
|
||||
:javascript
|
||||
$('.issue_search').keyup(function() {
|
||||
var terms = $(this).val();
|
||||
var project_id = 1;
|
||||
|
||||
if (terms.length >= 2) {
|
||||
$.get($(this).parent().attr('action'), { 'terms': terms, project: project_id }, function(response) {
|
||||
$('#issues-table').html(response);
|
||||
setSortable();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('.delete-issue').live('ajax:success', function() {
|
||||
$(this).closest('tr').fadeOut(); });
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue