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
Show 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
...
@@ -240,24 +240,26 @@ class ApplicationController < ActionController::Base
end
end
end
end
def
set_filters_
default
s
def
set_filters_
param
s
params
[
:sort
]
||=
'newest'
params
[
:sort
]
||=
'newest'
params
[
:scope
]
=
'all'
if
params
[
:scope
].
blank?
params
[
:scope
]
=
'all'
if
params
[
:scope
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
@
sort
=
params
[
:sort
].
humanize
@
filter_params
=
params
.
dup
if
@project
if
@project
params
[
:project_id
]
=
@project
.
id
@filter_
params
[
:project_id
]
=
@project
.
id
elsif
@group
elsif
@group
params
[
:group_id
]
=
@group
.
id
@filter_
params
[
:group_id
]
=
@group
.
id
else
else
params
[
:authorized_only
]
=
true
@filter_
params
[
:authorized_only
]
=
true
unless
params
[
:assignee_id
].
present?
unless
@filter_params
[
:assignee_id
]
params
[
:assignee_id
]
=
current_user
.
id
@filter_
params
[
:assignee_id
]
=
current_user
.
id
end
end
end
end
@filter_params
end
end
def
set_filter_values
(
collection
)
def
set_filter_values
(
collection
)
...
@@ -265,20 +267,35 @@ class ApplicationController < ActionController::Base
...
@@ -265,20 +267,35 @@ class ApplicationController < ActionController::Base
author_id
=
params
[
:author_id
]
author_id
=
params
[
:author_id
]
milestone_id
=
params
[
:milestone_id
]
milestone_id
=
params
[
:milestone_id
]
@sort
=
params
[
:sort
].
try
(
:humanize
)
@assignees
=
User
.
where
(
id:
collection
.
pluck
(
:assignee_id
))
@assignees
=
User
.
where
(
id:
collection
.
pluck
(
:assignee_id
))
@authors
=
User
.
where
(
id:
collection
.
pluck
(
:author_id
))
@authors
=
User
.
where
(
id:
collection
.
pluck
(
:author_id
))
@milestones
=
Milestone
.
where
(
id:
collection
.
pluck
(
:milestone_id
))
@milestones
=
Milestone
.
where
(
id:
collection
.
pluck
(
:milestone_id
))
if
assignee_id
.
present?
&&
!
assignee_id
.
to_i
.
zero?
if
assignee_id
.
present?
&&
!
assignee_id
.
to_i
.
zero?
@assignee
=
@assignees
.
find
(
assignee_id
)
@assignee
=
@assignees
.
find
_by
(
id:
assignee_id
)
end
end
if
author_id
.
present?
&&
!
author_id
.
to_i
.
zero?
if
author_id
.
present?
&&
!
author_id
.
to_i
.
zero?
@author
=
@authors
.
find
(
author_id
)
@author
=
@authors
.
find
_by
(
id:
author_id
)
end
end
if
milestone_id
.
present?
&&
!
milestone_id
.
to_i
.
zero?
if
milestone_id
.
present?
&&
!
milestone_id
.
to_i
.
zero?
@milestone
=
@milestones
.
find
(
milestone_id
)
@milestone
=
@milestones
.
find_by
(
id:
milestone_id
)
end
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
end
end
app/controllers/dashboard_controller.rb
View file @
016981c0
...
@@ -53,17 +53,13 @@ class DashboardController < ApplicationController
...
@@ -53,17 +53,13 @@ class DashboardController < ApplicationController
end
end
def
merge_requests
def
merge_requests
set_filters_defaults
@merge_requests
=
get_merge_requests_collection
@merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@merge_requests
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
preload
(
:author
,
:target_project
)
@merge_requests
=
@merge_requests
.
preload
(
:author
,
:target_project
)
end
end
def
issues
def
issues
set_filters_defaults
@issues
=
get_issues_collection
@issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@issues
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
preload
(
:author
,
:project
)
@issues
=
@issues
.
preload
(
:author
,
:project
)
...
...
app/controllers/groups_controller.rb
View file @
016981c0
...
@@ -45,17 +45,13 @@ class GroupsController < ApplicationController
...
@@ -45,17 +45,13 @@ class GroupsController < ApplicationController
end
end
def
merge_requests
def
merge_requests
set_filters_defaults
@merge_requests
=
get_merge_requests_collection
@merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@merge_requests
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
preload
(
:author
,
:target_project
)
@merge_requests
=
@merge_requests
.
preload
(
:author
,
:target_project
)
end
end
def
issues
def
issues
set_filters_defaults
@issues
=
get_issues_collection
@issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@issues
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
preload
(
:author
,
:project
)
@issues
=
@issues
.
preload
(
:author
,
:project
)
...
...
app/controllers/projects/issues_controller.rb
View file @
016981c0
...
@@ -18,9 +18,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -18,9 +18,7 @@ class Projects::IssuesController < Projects::ApplicationController
def
index
def
index
terms
=
params
[
'issue_search'
]
terms
=
params
[
'issue_search'
]
set_filters_defaults
@issues
=
get_issues_collection
@issues
=
IssuesFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@issues
)
@issues
=
@issues
.
full_search
(
terms
)
if
terms
.
present?
@issues
=
@issues
.
full_search
(
terms
)
if
terms
.
present?
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@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
...
@@ -17,9 +17,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_filter
:authorize_modify_merge_request!
,
only:
[
:close
,
:edit
,
:update
,
:sort
]
before_filter
:authorize_modify_merge_request!
,
only:
[
:close
,
:edit
,
:update
,
:sort
]
def
index
def
index
set_filters_defaults
@merge_requests
=
get_merge_requests_collection
@merge_requests
=
MergeRequestsFinder
.
new
.
execute
(
current_user
,
params
)
set_filter_values
(
@merge_requests
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
]).
per
(
20
)
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