Dashboard filters for events
This commit is contained in:
parent
899afd0067
commit
23734a715e
|
@ -653,3 +653,16 @@ pre {
|
||||||
margin-right:5px;
|
margin-right:5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard-search-filter {
|
||||||
|
padding:5px;
|
||||||
|
|
||||||
|
.search-text-input {
|
||||||
|
float:left;
|
||||||
|
@extend .span2;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
margin-left: 5px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
class DashboardController < ApplicationController
|
class DashboardController < ApplicationController
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
||||||
|
before_filter :projects
|
||||||
before_filter :event_filter, only: :index
|
before_filter :event_filter, only: :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@groups = Group.where(id: current_user.projects.pluck(:namespace_id))
|
@groups = Group.where(id: current_user.projects.pluck(:namespace_id))
|
||||||
@projects = current_user.projects_sorted_by_activity
|
|
||||||
@projects = @projects.page(params[:page]).per(30)
|
@projects = @projects.page(params[:page]).per(30)
|
||||||
|
|
||||||
@events = Event.in_projects(current_user.project_ids)
|
@events = Event.in_projects(current_user.project_ids)
|
||||||
@events = @event_filter.apply_filter(@events)
|
@events = @event_filter.apply_filter(@events)
|
||||||
@events = @events.limit(20).offset(params[:offset] || 0)
|
@events = @events.limit(20).offset(params[:offset] || 0)
|
||||||
|
@ -23,15 +22,16 @@ class DashboardController < ApplicationController
|
||||||
|
|
||||||
# Get authored or assigned open merge requests
|
# Get authored or assigned open merge requests
|
||||||
def merge_requests
|
def merge_requests
|
||||||
@projects = current_user.projects.all
|
@merge_requests = current_user.cared_merge_requests
|
||||||
@merge_requests = current_user.cared_merge_requests.recent.page(params[:page]).per(20)
|
@merge_requests = dashboard_filter(@merge_requests)
|
||||||
|
@merge_requests = @merge_requests.recent.page(params[:page]).per(20)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get only assigned issues
|
# Get only assigned issues
|
||||||
def issues
|
def issues
|
||||||
@projects = current_user.projects.all
|
@issues = current_user.assigned_issues
|
||||||
@user = current_user
|
@issues = dashboard_filter(@issues)
|
||||||
@issues = current_user.assigned_issues.opened.recent.page(params[:page]).per(20)
|
@issues = @issues.recent.page(params[:page]).per(20)
|
||||||
@issues = @issues.includes(:author, :project)
|
@issues = @issues.includes(:author, :project)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -40,7 +40,32 @@ class DashboardController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def projects
|
||||||
|
@projects = current_user.projects_sorted_by_activity
|
||||||
|
end
|
||||||
|
|
||||||
def event_filter
|
def event_filter
|
||||||
@event_filter ||= EventFilter.new(params[:event_filter])
|
@event_filter ||= EventFilter.new(params[:event_filter])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dashboard_filter items
|
||||||
|
if params[:project_id]
|
||||||
|
items = items.where(project_id: params[:project_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:search].present?
|
||||||
|
items = items.search(params[:search])
|
||||||
|
end
|
||||||
|
|
||||||
|
case params[:status]
|
||||||
|
when 'closed'
|
||||||
|
items.closed
|
||||||
|
when 'all'
|
||||||
|
items
|
||||||
|
else
|
||||||
|
items.opened
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
10
app/helpers/dashboard_helper.rb
Normal file
10
app/helpers/dashboard_helper.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
module DashboardHelper
|
||||||
|
def dashboard_filter_path(entity, options={})
|
||||||
|
case entity
|
||||||
|
when 'issue' then
|
||||||
|
dashboard_issues_path(options)
|
||||||
|
when 'merge_request'
|
||||||
|
dashboard_merge_requests_path(options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -269,4 +269,13 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def items_for entity
|
||||||
|
case entity
|
||||||
|
when 'issue' then
|
||||||
|
issues
|
||||||
|
when 'merge_request' then
|
||||||
|
merge_requests
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
32
app/views/dashboard/_filter.html.haml
Normal file
32
app/views/dashboard/_filter.html.haml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
= form_tag dashboard_filter_path(entity), method: 'get' do
|
||||||
|
%fieldset.dashboard-search-filter
|
||||||
|
= search_field_tag "search", nil, { placeholder: 'Search', class: 'search-text-input' }
|
||||||
|
= button_tag type: 'submit', class: 'btn' do
|
||||||
|
%i.icon-search
|
||||||
|
|
||||||
|
%fieldset
|
||||||
|
%legend Status:
|
||||||
|
%ul.nav.nav-pills.nav-stacked
|
||||||
|
%li{class: ("active" if !params[:status])}
|
||||||
|
= link_to dashboard_filter_path(entity) do
|
||||||
|
Open
|
||||||
|
%li{class: ("active" if params[:status] == 'closed')}
|
||||||
|
= link_to dashboard_filter_path(entity, status: 'closed') do
|
||||||
|
Closed
|
||||||
|
%li{class: ("active" if params[:status] == 'all')}
|
||||||
|
= link_to dashboard_filter_path(entity, status: 'all') do
|
||||||
|
All
|
||||||
|
|
||||||
|
%fieldset
|
||||||
|
%legend Projects:
|
||||||
|
%ul.nav.nav-pills.nav-stacked
|
||||||
|
- @projects.each do |project|
|
||||||
|
%li{class: ("active" if params[:project_id] == project.id.to_s)}
|
||||||
|
= link_to dashboard_filter_path(entity, project_id: project.id) do
|
||||||
|
= project.name_with_namespace
|
||||||
|
%small.right= project.items_for(entity).where(assignee_id: current_user.id).count
|
||||||
|
|
||||||
|
%fieldset
|
||||||
|
%hr
|
||||||
|
= link_to "Reset", dashboard_filter_path(entity), class: 'btn right'
|
||||||
|
|
|
@ -3,17 +3,21 @@
|
||||||
%small (assigned to you)
|
%small (assigned to you)
|
||||||
%small.right #{@issues.total_count} issues
|
%small.right #{@issues.total_count} issues
|
||||||
|
|
||||||
%br
|
%hr
|
||||||
.clearfix
|
|
||||||
- if @issues.any?
|
.row
|
||||||
- @issues.group_by(&:project).each do |group|
|
.span3
|
||||||
%div.ui-box
|
= render 'filter', entity: 'issue'
|
||||||
- @project = group[0]
|
.span9
|
||||||
%h5= @project.name
|
- if @issues.any?
|
||||||
%ul.unstyled.issues_table
|
- @issues.group_by(&:project).each do |group|
|
||||||
- group[1].each do |issue|
|
%div.ui-box
|
||||||
= render(partial: 'issues/show', locals: {issue: issue})
|
- @project = group[0]
|
||||||
%hr
|
%h5= @project.name
|
||||||
= paginate @issues, theme: "gitlab"
|
%ul.unstyled.issues_table
|
||||||
- else
|
- group[1].each do |issue|
|
||||||
%h3.nothing_here_message Nothing to show here
|
= render(partial: 'issues/show', locals: {issue: issue})
|
||||||
|
%hr
|
||||||
|
= paginate @issues, theme: "gitlab"
|
||||||
|
- else
|
||||||
|
%p.nothing_here_message Nothing to show here
|
||||||
|
|
|
@ -3,16 +3,20 @@
|
||||||
%small (authored by or assigned to you)
|
%small (authored by or assigned to you)
|
||||||
%small.right #{@merge_requests.total_count} merge requests
|
%small.right #{@merge_requests.total_count} merge requests
|
||||||
|
|
||||||
%br
|
%hr
|
||||||
- if @merge_requests.any?
|
.row
|
||||||
- @merge_requests.group_by(&:project).each do |group|
|
.span3
|
||||||
%ul.unstyled.ui-box
|
= render 'filter', entity: 'merge_request'
|
||||||
- @project = group[0]
|
.span9
|
||||||
%h5= @project.name
|
- if @merge_requests.any?
|
||||||
- group[1].each do |merge_request|
|
- @merge_requests.group_by(&:project).each do |group|
|
||||||
= render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request})
|
%ul.unstyled.ui-box
|
||||||
%hr
|
- @project = group[0]
|
||||||
= paginate @merge_requests, theme: "gitlab"
|
%h5= @project.name
|
||||||
|
- group[1].each do |merge_request|
|
||||||
|
= render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request})
|
||||||
|
%hr
|
||||||
|
= paginate @merge_requests, theme: "gitlab"
|
||||||
|
|
||||||
- else
|
- else
|
||||||
%h3.nothing_here_message Nothing to show here
|
%h3.nothing_here_message Nothing to show here
|
||||||
|
|
Loading…
Reference in a new issue