Context refactoring. Move Issues list, Search logic to context
This commit is contained in:
parent
63fe042d97
commit
679d0d6d76
15 changed files with 100 additions and 83 deletions
|
@ -1,7 +1,6 @@
|
|||
class IssuesController < ProjectResourceController
|
||||
before_filter :module_enabled
|
||||
before_filter :issue, only: [:edit, :update, :destroy, :show]
|
||||
helper_method :issues_filter
|
||||
|
||||
# Allow read any issue
|
||||
before_filter :authorize_read_issue!
|
||||
|
@ -19,7 +18,6 @@ class IssuesController < ProjectResourceController
|
|||
|
||||
def index
|
||||
@issues = issues_filtered
|
||||
|
||||
@issues = @issues.page(params[:page]).per(20)
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -54,7 +52,7 @@ class IssuesController < ProjectResourceController
|
|||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
if @issue.valid?
|
||||
if @issue.valid?
|
||||
redirect_to project_issue_path(@project, @issue)
|
||||
else
|
||||
render :new
|
||||
|
@ -69,7 +67,7 @@ class IssuesController < ProjectResourceController
|
|||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html do
|
||||
format.html do
|
||||
if @issue.valid?
|
||||
redirect_to [@project, @issue]
|
||||
else
|
||||
|
@ -134,35 +132,6 @@ class IssuesController < ProjectResourceController
|
|||
end
|
||||
|
||||
def issues_filtered
|
||||
@issues = case params[:f]
|
||||
when issues_filter[:all] then @project.issues
|
||||
when issues_filter[:closed] then @project.issues.closed
|
||||
when issues_filter[:to_me] then @project.issues.opened.assigned(current_user)
|
||||
else @project.issues.opened
|
||||
end
|
||||
|
||||
@issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present?
|
||||
@issues = @issues.includes(:author, :project).order("updated_at")
|
||||
|
||||
# Filter by specific assignee_id (or lack thereof)?
|
||||
if params[:assignee_id].present?
|
||||
@issues = @issues.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id]))
|
||||
end
|
||||
|
||||
# Filter by specific milestone_id (or lack thereof)?
|
||||
if params[:milestone_id].present?
|
||||
@issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id]))
|
||||
end
|
||||
|
||||
@issues
|
||||
end
|
||||
|
||||
def issues_filter
|
||||
{
|
||||
all: "all",
|
||||
closed: "closed",
|
||||
to_me: "assigned-to-me",
|
||||
open: "open"
|
||||
}
|
||||
@issues = IssuesListContext.new(project, current_user, params).execute
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue