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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a72f4630
Commit
a72f4630
authored
May 04, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sort by weight in issuable filter
parent
ee858d71
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
app/helpers/sorting_helper.rb
app/helpers/sorting_helper.rb
+19
-1
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+4
-0
app/views/shared/_sort_dropdown.html.haml
app/views/shared/_sort_dropdown.html.haml
+4
-0
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+19
-0
No files found.
app/helpers/sorting_helper.rb
View file @
a72f4630
...
...
@@ -14,7 +14,9 @@ module SortingHelper
sort_value_recently_signin
=>
sort_title_recently_signin
,
sort_value_oldest_signin
=>
sort_title_oldest_signin
,
sort_value_downvotes
=>
sort_title_downvotes
,
sort_value_upvotes
=>
sort_title_upvotes
sort_value_upvotes
=>
sort_title_upvotes
,
sort_value_more_weight
=>
sort_title_more_weight
,
sort_value_less_weight
=>
sort_title_less_weight
}
end
...
...
@@ -84,6 +86,14 @@ module SortingHelper
'Most popular'
end
def
sort_title_more_weight
'More weight'
end
def
sort_title_less_weight
'Less weight'
end
def
sort_value_oldest_updated
'updated_asc'
end
...
...
@@ -139,4 +149,12 @@ module SortingHelper
def
sort_value_upvotes
'upvotes_desc'
end
def
sort_value_more_weight
'weight_desc'
end
def
sort_value_less_weight
'weight_asc'
end
end
app/models/concerns/issuable.rb
View file @
a72f4630
...
...
@@ -38,6 +38,8 @@ module Issuable
scope
:order_milestone_due_desc
,
->
{
joins
(
:milestone
).
reorder
(
'milestones.due_date DESC, milestones.id DESC'
)
}
scope
:order_milestone_due_asc
,
->
{
joins
(
:milestone
).
reorder
(
'milestones.due_date ASC, milestones.id ASC'
)
}
scope
:without_label
,
->
{
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
name
}
' AND label_links.target_id =
#{
table_name
}
.id"
).
where
(
label_links:
{
id:
nil
})
}
scope
:order_weight_desc
,
->
{
reorder
(
'CASE WHEN weight IS NULL then 0 ELSE 1 END DESC, weight DESC'
)
}
scope
:order_weight_asc
,
->
{
reorder
(
'weight ASC'
)
}
scope
:join_project
,
->
{
joins
(
:project
)
}
scope
:references_project
,
->
{
references
(
:project
)
}
...
...
@@ -94,6 +96,8 @@ module Issuable
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'downvotes_desc'
then
order_downvotes_desc
when
'upvotes_desc'
then
order_upvotes_desc
when
'weight_desc'
then
order_weight_desc
when
'weight_asc'
then
order_weight_asc
else
order_by
(
method
)
end
...
...
app/views/shared/_sort_dropdown.html.haml
View file @
a72f4630
...
...
@@ -16,6 +16,10 @@
=
sort_title_recently_updated
=
link_to
page_filter_path
(
sort:
sort_value_oldest_updated
)
do
=
sort_title_oldest_updated
=
link_to
page_filter_path
(
sort:
sort_value_more_weight
)
do
=
sort_title_more_weight
=
link_to
page_filter_path
(
sort:
sort_value_less_weight
)
do
=
sort_title_less_weight
=
link_to
page_filter_path
(
sort:
sort_value_milestone_soon
)
do
=
sort_title_milestone_soon
=
link_to
page_filter_path
(
sort:
sort_value_milestone_later
)
do
...
...
spec/models/concerns/issuable_spec.rb
View file @
a72f4630
...
...
@@ -114,6 +114,25 @@ describe Issue, "Issuable" do
end
end
describe
"#sort"
do
let!
(
:issue
)
{
create
(
:issue
)
}
let
(
:project
)
{
issue
.
project
}
let!
(
:issue2
)
{
create
(
:issue
,
weight:
1
,
project:
project
)
}
let!
(
:issue3
)
{
create
(
:issue
,
weight:
2
,
project:
project
)
}
let!
(
:issue4
)
{
create
(
:issue
,
weight:
3
,
project:
project
)
}
it
"sorts by weight desc"
do
issues
=
Issue
.
where
(
project_id:
project
.
id
).
sort
(
'weight_desc'
)
expect
(
issues
).
to
match_array
([
issue4
,
issue3
,
issue2
,
issue
])
end
it
"sorts by weight asc"
do
issues
=
Issue
.
where
(
project_id:
project
.
id
).
sort
(
'weight_asc'
)
expect
(
issues
).
to
match_array
([
issue2
,
issue3
,
issue4
,
issue
])
end
end
describe
'#subscribed?'
do
context
'user is not a participant in the issue'
do
before
{
allow
(
issue
).
to
receive
(
:participants
).
with
(
user
).
and_return
([])
}
...
...
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