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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4a1dc732
Commit
4a1dc732
authored
Nov 23, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5661 from jasonblanchard/sorting-project-issues
Added sorting to project issues page
parents
abc5edab
b76948e6
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
206 additions
and
0 deletions
+206
-0
CHANGELOG
CHANGELOG
+3
-0
app/contexts/issues/list_context.rb
app/contexts/issues/list_context.rb
+18
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+3
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+2
-0
app/views/projects/issues/_issues.html.haml
app/views/projects/issues/_issues.html.haml
+20
-0
spec/contexts/issues/list_context_spec.rb
spec/contexts/issues/list_context_spec.rb
+77
-0
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+83
-0
No files found.
CHANGELOG
View file @
4a1dc732
v 6.4.0
- Added sorting to project issues page
v 6.3.0
v 6.3.0
- API for adding gitlab-ci service
- API for adding gitlab-ci service
- Init script now waits for pids to appear after (re)starting before reporting status (Rovanion Luckey)
- Init script now waits for pids to appear after (re)starting before reporting status (Rovanion Luckey)
...
...
app/contexts/issues/list_context.rb
View file @
4a1dc732
...
@@ -30,7 +30,25 @@ module Issues
...
@@ -30,7 +30,25 @@ module Issues
@issues
=
@issues
.
where
(
milestone_id:
(
params
[
:milestone_id
]
==
'0'
?
nil
:
params
[
:milestone_id
]))
@issues
=
@issues
.
where
(
milestone_id:
(
params
[
:milestone_id
]
==
'0'
?
nil
:
params
[
:milestone_id
]))
end
end
# Sort by :sort param
@issues
=
sort
(
@issues
,
params
[
:sort
])
@issues
@issues
end
end
private
def
sort
(
issues
,
condition
)
case
condition
when
'newest'
then
issues
.
except
(
:order
).
order
(
'created_at DESC'
)
when
'oldest'
then
issues
.
except
(
:order
).
order
(
'created_at ASC'
)
when
'recently_updated'
then
issues
.
except
(
:order
).
order
(
'updated_at DESC'
)
when
'last_updated'
then
issues
.
except
(
:order
).
order
(
'updated_at ASC'
)
when
'milestone_due_soon'
then
issues
.
except
(
:order
).
joins
(
:milestone
).
order
(
"milestones.due_date ASC"
)
when
'milestone_due_later'
then
issues
.
except
(
:order
).
joins
(
:milestone
).
order
(
"milestones.due_date DESC"
)
else
issues
end
end
end
end
end
end
app/controllers/projects/issues_controller.rb
View file @
4a1dc732
...
@@ -23,6 +23,9 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -23,6 +23,9 @@ class Projects::IssuesController < Projects::ApplicationController
assignee_id
,
milestone_id
=
params
[
:assignee_id
],
params
[
:milestone_id
]
assignee_id
,
milestone_id
=
params
[
:assignee_id
],
params
[
:milestone_id
]
@assignee
=
@project
.
team
.
find
(
assignee_id
)
if
assignee_id
.
present?
&&
!
assignee_id
.
to_i
.
zero?
@assignee
=
@project
.
team
.
find
(
assignee_id
)
if
assignee_id
.
present?
&&
!
assignee_id
.
to_i
.
zero?
@milestone
=
@project
.
milestones
.
find
(
milestone_id
)
if
milestone_id
.
present?
&&
!
milestone_id
.
to_i
.
zero?
@milestone
=
@project
.
milestones
.
find
(
milestone_id
)
if
milestone_id
.
present?
&&
!
milestone_id
.
to_i
.
zero?
sort_param
=
params
[
:sort
]
||
'newest'
@sort
=
sort_param
.
humanize
unless
sort_param
.
empty?
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
html
# index.html.erb
...
...
app/helpers/projects_helper.rb
View file @
4a1dc732
...
@@ -70,6 +70,8 @@ module ProjectsHelper
...
@@ -70,6 +70,8 @@ module ProjectsHelper
scope:
params
[
:scope
],
scope:
params
[
:scope
],
label_name:
params
[
:label_name
],
label_name:
params
[
:label_name
],
milestone_id:
params
[
:milestone_id
],
milestone_id:
params
[
:milestone_id
],
assignee_id:
params
[
:assignee_id
],
sort:
params
[
:sort
],
}
}
options
=
exist_opts
.
merge
(
options
)
options
=
exist_opts
.
merge
(
options
)
...
...
app/views/projects/issues/_issues.html.haml
View file @
4a1dc732
...
@@ -78,6 +78,26 @@
...
@@ -78,6 +78,26 @@
%strong
=
milestone
.
title
%strong
=
milestone
.
title
%small
.light
=
milestone
.
expires_at
%small
.light
=
milestone
.
expires_at
.dropdown.inline.prepend-left-10
%a
.dropdown-toggle.btn.btn-small
{
href:
'#'
,
"data-toggle"
=>
"dropdown"
}
%span
.light
sort:
=
@sort
%b
.caret
%ul
.dropdown-menu
%li
=
link_to
project_filter_path
(
sort:
'newest'
)
do
Newest
=
link_to
project_filter_path
(
sort:
'oldest'
)
do
Oldest
=
link_to
project_filter_path
(
sort:
'recently_updated'
)
do
Recently updated
=
link_to
project_filter_path
(
sort:
'last_updated'
)
do
Last updated
=
link_to
project_filter_path
(
sort:
'milestone_due_soon'
)
do
Milestone due soon
=
link_to
project_filter_path
(
sort:
'milestone_due_later'
)
do
Milestone due later
%ul
.well-list.issues-list
%ul
.well-list.issues-list
=
render
@issues
=
render
@issues
...
...
spec/contexts/issues/list_context_spec.rb
0 → 100644
View file @
4a1dc732
require
'spec_helper'
describe
Issues
::
ListContext
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
creator:
user
)
}
titles
=
[
'foo'
,
'bar'
,
'baz'
]
titles
.
each_with_index
do
|
title
,
index
|
let!
(
title
.
to_sym
)
{
create
(
:issue
,
title:
title
,
project:
project
,
created_at:
Time
.
now
-
(
index
*
60
))
}
end
describe
'sorting'
do
it
'sorts by newest'
do
params
=
{
:sort
=>
'newest'
}
issues
=
Issues
::
ListContext
.
new
(
project
,
user
,
params
).
execute
issues
.
first
.
should
eq
foo
end
it
'sorts by oldest'
do
params
=
{
:sort
=>
'oldest'
}
issues
=
Issues
::
ListContext
.
new
(
project
,
user
,
params
).
execute
issues
.
first
.
should
eq
baz
end
it
'sorts by recently updated'
do
params
=
{
:sort
=>
'recently_updated'
}
baz
.
updated_at
=
Time
.
now
+
10
baz
.
save
issues
=
Issues
::
ListContext
.
new
(
project
,
user
,
params
).
execute
issues
.
first
.
should
eq
baz
end
it
'sorts by least recently updated'
do
params
=
{
:sort
=>
'last_updated'
}
bar
.
updated_at
=
Time
.
now
-
10
bar
.
save
issues
=
Issues
::
ListContext
.
new
(
project
,
user
,
params
).
execute
issues
.
first
.
should
eq
bar
end
describe
'sorting by milestone'
do
let
(
:newer_due_milestone
)
{
create
(
:milestone
,
:due_date
=>
'2013-12-11'
)
}
let
(
:later_due_milestone
)
{
create
(
:milestone
,
:due_date
=>
'2013-12-12'
)
}
before
:each
do
foo
.
milestone
=
newer_due_milestone
foo
.
save
bar
.
milestone
=
later_due_milestone
bar
.
save
end
it
'sorts by most recently due milestone'
do
params
=
{
:sort
=>
'milestone_due_soon'
}
issues
=
Issues
::
ListContext
.
new
(
project
,
user
,
params
).
execute
issues
.
first
.
should
eq
foo
end
it
'sorts by least recently due milestone'
do
params
=
{
:sort
=>
'milestone_due_later'
}
issues
=
Issues
::
ListContext
.
new
(
project
,
user
,
params
).
execute
issues
.
first
.
should
eq
bar
end
end
end
end
spec/features/issues_spec.rb
View file @
4a1dc732
...
@@ -95,4 +95,87 @@ describe "Issues" do
...
@@ -95,4 +95,87 @@ describe "Issues" do
page
.
should
have_content
'gitlab'
page
.
should
have_content
'gitlab'
end
end
end
end
describe
'filter issue'
do
titles
=
[
'foo'
,
'bar'
,
'baz'
]
titles
.
each_with_index
do
|
title
,
index
|
let!
(
title
.
to_sym
)
{
create
(
:issue
,
title:
title
,
project:
project
,
created_at:
Time
.
now
-
(
index
*
60
))
}
end
let
(
:newer_due_milestone
)
{
create
(
:milestone
,
:due_date
=>
'2013-12-11'
)
}
let
(
:later_due_milestone
)
{
create
(
:milestone
,
:due_date
=>
'2013-12-12'
)
}
it
'sorts by newest'
do
visit
project_issues_path
(
project
,
sort:
'newest'
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'foo'
)
page
.
should
have_selector
(
"ul.issues-list li:last-child"
,
:text
=>
'baz'
)
end
it
'sorts by oldest'
do
visit
project_issues_path
(
project
,
sort:
'oldest'
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'baz'
)
page
.
should
have_selector
(
"ul.issues-list li:last-child"
,
:text
=>
'foo'
)
end
it
'sorts by most recently updated'
do
baz
.
updated_at
=
Time
.
now
+
100
baz
.
save
visit
project_issues_path
(
project
,
sort:
'recently_updated'
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'baz'
)
end
it
'sorts by least recently updated'
do
baz
.
updated_at
=
Time
.
now
-
100
baz
.
save
visit
project_issues_path
(
project
,
sort:
'last_updated'
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'baz'
)
end
describe
'sorting by milestone'
do
before
:each
do
foo
.
milestone
=
newer_due_milestone
foo
.
save
bar
.
milestone
=
later_due_milestone
bar
.
save
end
it
'sorts by recently due milestone'
do
visit
project_issues_path
(
project
,
sort:
'milestone_due_soon'
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'foo'
)
end
it
'sorts by least recently due milestone'
do
visit
project_issues_path
(
project
,
sort:
'milestone_due_later'
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'bar'
)
end
end
describe
'combine filter and sort'
do
let
(
:user2
)
{
create
(
:user
)
}
before
:each
do
foo
.
assignee
=
user2
foo
.
save
bar
.
assignee
=
user2
bar
.
save
end
it
'sorts with a filter applied'
do
visit
project_issues_path
(
project
,
sort:
'oldest'
,
assignee_id:
user2
.
id
)
page
.
should
have_selector
(
"ul.issues-list li:first-child"
,
:text
=>
'bar'
)
page
.
should
have_selector
(
"ul.issues-list li:last-child"
,
:text
=>
'foo'
)
page
.
should_not
have_content
'baz'
end
end
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