2012-10-09 15:09:46 -04:00
|
|
|
class IssuesListContext < BaseContext
|
|
|
|
include IssuesHelper
|
|
|
|
|
|
|
|
attr_accessor :issues
|
|
|
|
|
|
|
|
def execute
|
2013-01-05 07:49:08 -05:00
|
|
|
@issues = case params[:status]
|
2012-10-09 15:09:46 -04:00
|
|
|
when issues_filter[:all] then @project.issues
|
|
|
|
when issues_filter[:closed] then @project.issues.closed
|
2013-02-28 10:46:28 -05:00
|
|
|
when issues_filter[:to_me] then @project.issues.assigned(current_user)
|
|
|
|
when issues_filter[:by_me] then @project.issues.authored(current_user)
|
2012-10-09 15:09:46 -04:00
|
|
|
else @project.issues.opened
|
|
|
|
end
|
|
|
|
|
|
|
|
@issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present?
|
2013-02-28 10:46:28 -05:00
|
|
|
@issues = @issues.includes(:author, :project)
|
2012-10-09 15:09:46 -04:00
|
|
|
|
|
|
|
# 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
|
|
|
|
end
|