Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
92f6de03
Commit
92f6de03
authored
Oct 25, 2011
by
Adam Leonard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If terms are removed show all results for current status
parent
09558634
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
20 deletions
+61
-20
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+11
-2
app/views/issues/index.html.haml
app/views/issues/index.html.haml
+19
-12
spec/requests/issues_spec.rb
spec/requests/issues_spec.rb
+31
-6
No files found.
app/controllers/issues_controller.rb
View file @
92f6de03
...
...
@@ -79,8 +79,17 @@ class IssuesController < ApplicationController
end
def
search
@project
=
Project
.
find
(
params
[
'project'
])
@issues
=
@project
.
issues
.
where
(
"title LIKE ? OR content LIKE ?"
,
"%
#{
params
[
'terms'
]
}
%"
,
"%
#{
params
[
'terms'
]
}
%"
)
terms
=
params
[
'terms'
]
@project
=
Project
.
find
(
params
[
'project'
])
@issues
=
case
params
[
:status
].
to_i
when
1
then
@project
.
issues
when
2
then
@project
.
issues
.
closed
when
3
then
@project
.
issues
.
opened
.
assigned
(
current_user
)
else
@project
.
issues
.
opened
end
@issues
=
@issues
.
where
(
"title LIKE ? OR content LIKE ?"
,
"%
#{
terms
}
%"
,
"%
#{
terms
}
%"
)
unless
terms
.
blank?
render
:partial
=>
'issues'
end
...
...
app/views/issues/index.html.haml
View file @
92f6de03
...
...
@@ -2,37 +2,44 @@
-
if
can?
current_user
,
:write_issue
,
@project
.left
=
form_tag
search_project_issues_path
(
@project
),
:method
=>
:get
,
:remote
=>
true
do
=
hidden_field_tag
:project_id
,
@project
.
id
,
{
:id
=>
'project_id'
}
=
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
=
radio_button_tag
:f
,
0
,
(
params
[
:f
]
||
"0"
)
==
"0"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"open_issues"
=
radio_button_tag
:f
,
0
,
(
params
[
:f
]
||
"0"
)
==
"0"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"open_issues"
,
:class
=>
"status"
=
label_tag
"open_issues"
,
"Open"
.span-2
=
radio_button_tag
:f
,
2
,
params
[
:f
]
==
"2"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"closed_issues"
=
radio_button_tag
:f
,
2
,
params
[
:f
]
==
"2"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"closed_issues"
,
:class
=>
"status"
=
label_tag
"closed_issues"
,
"Closed"
.span-2
=
radio_button_tag
:f
,
3
,
params
[
:f
]
==
"3"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"my_issues"
=
radio_button_tag
:f
,
3
,
params
[
:f
]
==
"3"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"my_issues"
,
:class
=>
"status"
=
label_tag
"my_issues"
,
"To Me"
.span-2
=
radio_button_tag
:f
,
1
,
params
[
:f
]
==
"1"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"all_issues"
=
radio_button_tag
:f
,
1
,
params
[
:f
]
==
"1"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"all_issues"
,
:class
=>
"status"
=
label_tag
"all_issues"
,
"All"
#issues-table-holder
=
render
"issues"
%br
:javascript
var
href
=
$
(
'
.issue_search
'
).
parent
().
attr
(
'
action
'
);
var
last_terms
=
''
;
$
(
'
.issue_search
'
).
keyup
(
function
()
{
var
terms
=
$
(
this
).
val
();
var
project_id
=
1
;
var
terms
=
$
(
this
).
val
();
var
project_id
=
$
(
'
#project_id
'
).
val
();
var
status
=
$
(
'
.status:checked
'
).
val
();
if
(
terms
!=
last_terms
)
{
last_terms
=
terms
;
if
(
terms
.
length
>=
2
)
{
$
.
get
(
$
(
this
).
parent
().
attr
(
'
action
'
),
{
'
terms
'
:
terms
,
project
:
project_id
},
function
(
response
)
{
$
(
'
#issues-table
'
).
html
(
response
);
setSortable
();
});
if
(
terms
.
length
>=
2
||
terms
.
length
==
0
)
{
$
.
get
(
href
,
{
'
status
'
:
status
,
'
terms
'
:
terms
,
project
:
project_id
},
function
(
response
)
{
$
(
'
#issues-table
'
).
html
(
response
);
setSortable
();
});
}
}
});
...
...
spec/requests/issues_spec.rb
View file @
92f6de03
...
...
@@ -149,21 +149,46 @@ describe "Issues" do
before
do
[
'foobar'
,
'foobar2'
,
'gitlab'
].
each
do
|
title
|
@issue
=
Factory
:issue
,
:author
=>
@user
,
:author
=>
@user
,
:assignee
=>
@user
,
:project
=>
project
,
:title
=>
title
:project
=>
project
,
:title
=>
title
@issue
.
save
end
end
it
"should search and return the correct results"
do
it
"should be able to search on different statuses"
do
@issue
=
Issue
.
first
@issue
.
closed
=
true
@issue
.
save
visit
project_issues_path
(
project
)
fill_in
"issue_search"
,
:with
=>
"foobar"
choose
'closed_issues'
fill_in
'issue_search'
,
:with
=>
'foobar'
page
.
should
have_content
'foobar'
page
.
should_not
have_content
'foobar2'
page
.
should_not
have_content
'gitlab'
end
it
"should search for term and return the correct results"
do
visit
project_issues_path
(
project
)
fill_in
'issue_search'
,
:with
=>
'foobar'
page
.
should
have_content
'foobar'
page
.
should
have_content
'foobar2'
page
.
should_not
have_content
'gitlab'
end
end
it
"should return all results if term has been cleared"
do
visit
project_issues_path
(
project
)
fill_in
"issue_search"
,
:with
=>
"foobar"
# Because fill_in, :with => "" triggers nothing we need to trigger a keyup event
page
.
execute_script
(
"$('.issue_search').val('').keyup();"
);
page
.
should
have_content
'foobar'
page
.
should
have_content
'foobar2'
page
.
should
have_content
'gitlab'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment