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
016981c0
Commit
016981c0
authored
Dec 24, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor issuable list pages
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
47634e39
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
28 deletions
+33
-28
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+27
-10
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+2
-6
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+2
-6
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-3
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-3
No files found.
app/controllers/application_controller.rb
View file @
016981c0
...
...
@@ -240,24 +240,26 @@ class ApplicationController < ActionController::Base
end
end
def
set_filters_
default
s
def
set_filters_
param
s
params
[
:sort
]
||=
'newest'
params
[
:scope
]
=
'all'
if
params
[
:scope
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
@
sort
=
params
[
:sort
].
humanize
@
filter_params
=
params
.
dup
if
@project
params
[
:project_id
]
=
@project
.
id
@filter_
params
[
:project_id
]
=
@project
.
id
elsif
@group
params
[
:group_id
]
=
@group
.
id
@filter_
params
[
:group_id
]
=
@group
.
id
else
params
[
:authorized_only
]
=
true
@filter_
params
[
:authorized_only
]
=
true
unless
params
[
:assignee_id
].
present?
params
[
:assignee_id
]
=
current_user
.
id
unless
@filter_params
[
:assignee_id
]
@filter_
params
[
:assignee_id
]
=
current_user
.
id
end
end
@filter_params
end
def
set_filter_values
(
collection
)
...
...
@@ -265,20 +267,35 @@ class ApplicationController < ActionController::Base
author_id
=
params
[
:author_id
]
milestone_id
=
params
[
:milestone_id
]
@sort
=
params
[
:sort
].
try
(
:humanize
)
@assignees
=
User
.
where
(
id:
collection
.
pluck
(
:assignee_id
))
@authors
=
User
.
where
(
id:
collection
.
pluck
(
:author_id
))
@milestones
=
Milestone
.
where
(
id:
collection
.
pluck
(
:milestone_id
))
if
assignee_id
.
present?
&&
!
assignee_id
.
to_i
.
zero?
@assignee
=
@assignees
.
find
(
assignee_id
)
@assignee
=
@assignees
.
find
_by
(
id:
assignee_id
)
end
if
author_id
.
present?
&&
!
author_id
.
to_i
.
zero?
@author
=
@authors
.
find
(
author_id
)
@author
=
@authors
.
find
_by
(
id:
author_id
)
end
if
milestone_id
.
present?
&&
!
milestone_id
.
to_i
.
zero?
@milestone
=
@milestones
.
find
(
milestone_id
)
@milestone
=
@milestones
.
find
_by
(
id:
milestone_id
)
end
end
def
get_issues_collection
set_filters_params
issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
@filter_params
)
set_filter_values
(
issues
)
issues
end
def
get_merge_requests_collection
set_filters_params
merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
@filter_params
)
set_filter_values
(
merge_requests
)
merge_requests
end
end
app/controllers/dashboard_controller.rb
View file @
016981c0
...
...
@@ -53,17 +53,13 @@ class DashboardController < ApplicationController
end
def
merge_requests
set_filters_defaults
@merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@merge_requests
)
@merge_requests
=
get_merge_requests_collection
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
preload
(
:author
,
:target_project
)
end
def
issues
set_filters_defaults
@issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@issues
)
@issues
=
get_issues_collection
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
preload
(
:author
,
:project
)
...
...
app/controllers/groups_controller.rb
View file @
016981c0
...
...
@@ -45,17 +45,13 @@ class GroupsController < ApplicationController
end
def
merge_requests
set_filters_defaults
@merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@merge_requests
)
@merge_requests
=
get_merge_requests_collection
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
preload
(
:author
,
:target_project
)
end
def
issues
set_filters_defaults
@issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@issues
)
@issues
=
get_issues_collection
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
preload
(
:author
,
:project
)
...
...
app/controllers/projects/issues_controller.rb
View file @
016981c0
...
...
@@ -18,9 +18,7 @@ class Projects::IssuesController < Projects::ApplicationController
def
index
terms
=
params
[
'issue_search'
]
set_filters_defaults
@issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@issues
)
@issues
=
get_issues_collection
@issues
=
@issues
.
full_search
(
terms
)
if
terms
.
present?
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
016981c0
...
...
@@ -17,9 +17,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_filter
:authorize_modify_merge_request!
,
only:
[
:close
,
:edit
,
:update
,
:sort
]
def
index
set_filters_defaults
@merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@merge_requests
)
@merge_requests
=
get_merge_requests_collection
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
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