Added search for issues

This commit is contained in:
Shrey 2015-06-10 12:34:26 +05:30 committed by Matt Amos
parent c7bc13668b
commit 0a3dd82c47
4 changed files with 31 additions and 1 deletions

View file

@ -7,7 +7,22 @@ class IssuesController < ApplicationController
before_action :find_issue, only: [:show, :resolve, :reopen, :ignore]
def index
@issues = Issue.all.order(:status)
if params[:search_by_user].present?
@user = User.find_by_display_name(params[:search_by_user])
if @user.present?
@issues = Issue.where(reported_user_id: @user.id).order(:status)
else
@issues = Issue.all.order(:status)
redirect_to issues_path, notice: t('issues.index.search.user_not_found')
end
if @user.present? and not @issues.present?
@issues = Issue.all.order(:status)
redirect_to issues_path, notice: t('issues.index.search.issues_not_found')
end
else
@issues = Issue.all.order(:status)
end
end
def show

View file

@ -4,6 +4,13 @@
<h1>List of existing Issues:</h1>
<% end %>
<%= form_tag(issues_path, :method => :get) do %>
<%= text_field_tag :search_by_user, params[:search_by_user], placeholder: "Search by Reported User" %>
<%= submit_tag "Search" %>
<% end %>
<br/>
<br/>
<table>
<thead>
<tr>

View file

@ -940,6 +940,10 @@ en-GB:
resolve: Resolve
ignore: Ignore
reopen: Reopen
index:
search:
user_not_found: User does not exist
issues_not_found: No Issues against the user
create:
successful_report: Your report has been registered sucessfully
provide_details: Please provide the required details

View file

@ -910,6 +910,10 @@ en:
resolve: Resolve
ignore: Ignore
reopen: Reopen
index:
search:
user_not_found: User does not exist
issues_not_found: No Issues against the user
create:
successful_report: Your report has been registered sucessfully
provide_details: Please provide the required details