Commit 23734a715e622f3f028bd565df3be130d3aba737
1 parent
899afd00
Exists in
master
and in
4 other branches
Dashboard filters for events
Showing
7 changed files
with
130 additions
and
33 deletions
Show diff stats
app/assets/stylesheets/common.scss
app/controllers/dashboard_controller.rb
| 1 | 1 | class DashboardController < ApplicationController |
| 2 | 2 | respond_to :html |
| 3 | 3 | |
| 4 | + before_filter :projects | |
| 4 | 5 | before_filter :event_filter, only: :index |
| 5 | 6 | |
| 6 | 7 | def index |
| 7 | 8 | @groups = Group.where(id: current_user.projects.pluck(:namespace_id)) |
| 8 | - @projects = current_user.projects_sorted_by_activity | |
| 9 | 9 | @projects = @projects.page(params[:page]).per(30) |
| 10 | - | |
| 11 | 10 | @events = Event.in_projects(current_user.project_ids) |
| 12 | 11 | @events = @event_filter.apply_filter(@events) |
| 13 | 12 | @events = @events.limit(20).offset(params[:offset] || 0) |
| ... | ... | @@ -23,15 +22,16 @@ class DashboardController < ApplicationController |
| 23 | 22 | |
| 24 | 23 | # Get authored or assigned open merge requests |
| 25 | 24 | def merge_requests |
| 26 | - @projects = current_user.projects.all | |
| 27 | - @merge_requests = current_user.cared_merge_requests.recent.page(params[:page]).per(20) | |
| 25 | + @merge_requests = current_user.cared_merge_requests | |
| 26 | + @merge_requests = dashboard_filter(@merge_requests) | |
| 27 | + @merge_requests = @merge_requests.recent.page(params[:page]).per(20) | |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | # Get only assigned issues |
| 31 | 31 | def issues |
| 32 | - @projects = current_user.projects.all | |
| 33 | - @user = current_user | |
| 34 | - @issues = current_user.assigned_issues.opened.recent.page(params[:page]).per(20) | |
| 32 | + @issues = current_user.assigned_issues | |
| 33 | + @issues = dashboard_filter(@issues) | |
| 34 | + @issues = @issues.recent.page(params[:page]).per(20) | |
| 35 | 35 | @issues = @issues.includes(:author, :project) |
| 36 | 36 | |
| 37 | 37 | respond_to do |format| |
| ... | ... | @@ -40,7 +40,32 @@ class DashboardController < ApplicationController |
| 40 | 40 | end |
| 41 | 41 | end |
| 42 | 42 | |
| 43 | + protected | |
| 44 | + | |
| 45 | + def projects | |
| 46 | + @projects = current_user.projects_sorted_by_activity | |
| 47 | + end | |
| 48 | + | |
| 43 | 49 | def event_filter |
| 44 | 50 | @event_filter ||= EventFilter.new(params[:event_filter]) |
| 45 | 51 | end |
| 52 | + | |
| 53 | + def dashboard_filter items | |
| 54 | + if params[:project_id] | |
| 55 | + items = items.where(project_id: params[:project_id]) | |
| 56 | + end | |
| 57 | + | |
| 58 | + if params[:search].present? | |
| 59 | + items = items.search(params[:search]) | |
| 60 | + end | |
| 61 | + | |
| 62 | + case params[:status] | |
| 63 | + when 'closed' | |
| 64 | + items.closed | |
| 65 | + when 'all' | |
| 66 | + items | |
| 67 | + else | |
| 68 | + items.opened | |
| 69 | + end | |
| 70 | + end | |
| 46 | 71 | end | ... | ... |
app/models/project.rb
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | += form_tag dashboard_filter_path(entity), method: 'get' do | |
| 2 | + %fieldset.dashboard-search-filter | |
| 3 | + = search_field_tag "search", nil, { placeholder: 'Search', class: 'search-text-input' } | |
| 4 | + = button_tag type: 'submit', class: 'btn' do | |
| 5 | + %i.icon-search | |
| 6 | + | |
| 7 | + %fieldset | |
| 8 | + %legend Status: | |
| 9 | + %ul.nav.nav-pills.nav-stacked | |
| 10 | + %li{class: ("active" if !params[:status])} | |
| 11 | + = link_to dashboard_filter_path(entity) do | |
| 12 | + Open | |
| 13 | + %li{class: ("active" if params[:status] == 'closed')} | |
| 14 | + = link_to dashboard_filter_path(entity, status: 'closed') do | |
| 15 | + Closed | |
| 16 | + %li{class: ("active" if params[:status] == 'all')} | |
| 17 | + = link_to dashboard_filter_path(entity, status: 'all') do | |
| 18 | + All | |
| 19 | + | |
| 20 | + %fieldset | |
| 21 | + %legend Projects: | |
| 22 | + %ul.nav.nav-pills.nav-stacked | |
| 23 | + - @projects.each do |project| | |
| 24 | + %li{class: ("active" if params[:project_id] == project.id.to_s)} | |
| 25 | + = link_to dashboard_filter_path(entity, project_id: project.id) do | |
| 26 | + = project.name_with_namespace | |
| 27 | + %small.right= project.items_for(entity).where(assignee_id: current_user.id).count | |
| 28 | + | |
| 29 | + %fieldset | |
| 30 | + %hr | |
| 31 | + = link_to "Reset", dashboard_filter_path(entity), class: 'btn right' | |
| 32 | + | ... | ... |
app/views/dashboard/issues.html.haml
| ... | ... | @@ -3,17 +3,21 @@ |
| 3 | 3 | %small (assigned to you) |
| 4 | 4 | %small.right #{@issues.total_count} issues |
| 5 | 5 | |
| 6 | -%br | |
| 7 | -.clearfix | |
| 8 | -- if @issues.any? | |
| 9 | - - @issues.group_by(&:project).each do |group| | |
| 10 | - %div.ui-box | |
| 11 | - - @project = group[0] | |
| 12 | - %h5= @project.name | |
| 13 | - %ul.unstyled.issues_table | |
| 14 | - - group[1].each do |issue| | |
| 15 | - = render(partial: 'issues/show', locals: {issue: issue}) | |
| 16 | - %hr | |
| 17 | - = paginate @issues, theme: "gitlab" | |
| 18 | -- else | |
| 19 | - %h3.nothing_here_message Nothing to show here | |
| 6 | +%hr | |
| 7 | + | |
| 8 | +.row | |
| 9 | + .span3 | |
| 10 | + = render 'filter', entity: 'issue' | |
| 11 | + .span9 | |
| 12 | + - if @issues.any? | |
| 13 | + - @issues.group_by(&:project).each do |group| | |
| 14 | + %div.ui-box | |
| 15 | + - @project = group[0] | |
| 16 | + %h5= @project.name | |
| 17 | + %ul.unstyled.issues_table | |
| 18 | + - group[1].each do |issue| | |
| 19 | + = render(partial: 'issues/show', locals: {issue: issue}) | |
| 20 | + %hr | |
| 21 | + = paginate @issues, theme: "gitlab" | |
| 22 | + - else | |
| 23 | + %p.nothing_here_message Nothing to show here | ... | ... |
app/views/dashboard/merge_requests.html.haml
| ... | ... | @@ -3,16 +3,20 @@ |
| 3 | 3 | %small (authored by or assigned to you) |
| 4 | 4 | %small.right #{@merge_requests.total_count} merge requests |
| 5 | 5 | |
| 6 | -%br | |
| 7 | -- if @merge_requests.any? | |
| 8 | - - @merge_requests.group_by(&:project).each do |group| | |
| 9 | - %ul.unstyled.ui-box | |
| 10 | - - @project = group[0] | |
| 11 | - %h5= @project.name | |
| 12 | - - group[1].each do |merge_request| | |
| 13 | - = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) | |
| 14 | - %hr | |
| 15 | - = paginate @merge_requests, theme: "gitlab" | |
| 6 | +%hr | |
| 7 | +.row | |
| 8 | + .span3 | |
| 9 | + = render 'filter', entity: 'merge_request' | |
| 10 | + .span9 | |
| 11 | + - if @merge_requests.any? | |
| 12 | + - @merge_requests.group_by(&:project).each do |group| | |
| 13 | + %ul.unstyled.ui-box | |
| 14 | + - @project = group[0] | |
| 15 | + %h5= @project.name | |
| 16 | + - group[1].each do |merge_request| | |
| 17 | + = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) | |
| 18 | + %hr | |
| 19 | + = paginate @merge_requests, theme: "gitlab" | |
| 16 | 20 | |
| 17 | -- else | |
| 18 | - %h3.nothing_here_message Nothing to show here | |
| 21 | + - else | |
| 22 | + %h3.nothing_here_message Nothing to show here | ... | ... |