created-by-me filter for issues inside project. Fixed global project.issues order
This commit is contained in:
parent
15b121d603
commit
115454f3ed
5 changed files with 14 additions and 5 deletions
|
@ -7,12 +7,13 @@ class IssuesListContext < BaseContext
|
|||
@issues = case params[:status]
|
||||
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)
|
||||
when issues_filter[:to_me] then @project.issues.assigned(current_user)
|
||||
when issues_filter[:by_me] then @project.issues.authored(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")
|
||||
@issues = @issues.includes(:author, :project)
|
||||
|
||||
# Filter by specific assignee_id (or lack thereof)?
|
||||
if params[:assignee_id].present?
|
||||
|
|
|
@ -27,6 +27,7 @@ module IssuesHelper
|
|||
all: "all",
|
||||
closed: "closed",
|
||||
to_me: "assigned-to-me",
|
||||
by_me: "created-by-me",
|
||||
open: "open"
|
||||
}
|
||||
end
|
||||
|
@ -45,7 +46,7 @@ module IssuesHelper
|
|||
return "" if @project.nil?
|
||||
|
||||
if @project.used_default_issues_tracker?
|
||||
project_issues_filter_path(@project)
|
||||
project_issues_filter_path(@project)
|
||||
else
|
||||
url = Settings[:issues_tracker][@project.issues_tracker]["project_url"]
|
||||
url.gsub(':project_id', @project.id.to_s)
|
||||
|
|
|
@ -30,6 +30,10 @@ class Issue < ActiveRecord::Base
|
|||
where('assignee_id = :user', user: user.id)
|
||||
end
|
||||
|
||||
def authored(user)
|
||||
where('author_id = :user', user: user.id)
|
||||
end
|
||||
|
||||
def open_for(user)
|
||||
opened.assigned(user)
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ class Project < ActiveRecord::Base
|
|||
|
||||
has_many :events, dependent: :destroy
|
||||
has_many :merge_requests, dependent: :destroy
|
||||
has_many :issues, dependent: :destroy, order: "state, created_at DESC"
|
||||
has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC"
|
||||
has_many :milestones, dependent: :destroy
|
||||
has_many :users_projects, dependent: :destroy
|
||||
has_many :notes, dependent: :destroy
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
Open
|
||||
%li{class: ("active" if params[:status] == 'assigned-to-me')}
|
||||
= link_to project_issues_path(@project, status: 'assigned-to-me') do
|
||||
Assigned To Me
|
||||
Assigned to me
|
||||
%li{class: ("active" if params[:status] == 'created-by-me')}
|
||||
= link_to project_issues_path(@project, status: 'created-by-me') do
|
||||
Created by me
|
||||
%li{class: ("active" if params[:status] == 'closed')}
|
||||
= link_to project_issues_path(@project, status: 'closed') do
|
||||
Closed
|
||||
|
|
Loading…
Reference in a new issue