OSDN Git Service

Show Assigned/Authored/All filter for dashboard issues and mr pages
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 24 Dec 2013 12:53:52 +0000 (14:53 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 24 Dec 2013 12:53:52 +0000 (14:53 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/controllers/dashboard_controller.rb
app/views/dashboard/issues.html.haml
app/views/dashboard/merge_requests.html.haml
app/views/layouts/nav/_dashboard.html.haml
app/views/shared/_filter.html.haml

index aaab4b4..70dd3ff 100644 (file)
@@ -50,16 +50,30 @@ class DashboardController < ApplicationController
     @projects = @projects.page(params[:page]).per(30)
   end
 
-  # Get authored or assigned open merge requests
   def merge_requests
-    @merge_requests = current_user.cared_merge_requests
+    @merge_requests = case params[:scope]
+                      when 'authored' then
+                        current_user.merge_requests
+                      when 'all' then
+                        MergeRequest.where(target_project_id: current_user.authorized_projects.pluck(:id))
+                      else
+                        current_user.assigned_merge_requests
+                      end
+
     @merge_requests = FilterContext.new(@merge_requests, params).execute
     @merge_requests = @merge_requests.recent.page(params[:page]).per(20)
   end
 
-  # Get only assigned issues
   def issues
-    @issues = current_user.assigned_issues
+    @issues = case params[:scope]
+              when 'authored' then
+                current_user.issues
+              when 'all' then
+                Issue.where(project_id: current_user.authorized_projects.pluck(:id))
+              else
+                current_user.assigned_issues
+              end
+
     @issues = FilterContext.new(@issues, params).execute
     @issues = @issues.recent.page(params[:page]).per(20)
     @issues = @issues.includes(:author, :project)
index 82880d5..bda5b7c 100644 (file)
@@ -1,9 +1,9 @@
 %h3.page-title
-  Issues assigned to me
+  Issues
   %span.pull-right #{@issues.total_count} issues
 
 %p.light
-  For all issues you should visit the project's issues page, or use the search panel to find a specific issue.
+  List all issues from all project's you have access to.
 %hr
 
 .row
index 9c96ede..74d0233 100644 (file)
@@ -4,7 +4,7 @@
 
 
 %p.light
-  Only merge requests created by you or assigned to you are listed here.
+  List all merge requests from all project's you have access to.
 %hr
 .row
   .span3
index cae24c3..12fd49e 100644 (file)
@@ -12,7 +12,7 @@
   = nav_link(path: 'dashboard#merge_requests') do
     = link_to merge_requests_dashboard_path do
       Merge Requests
-      %span.count= current_user.cared_merge_requests.opened.count
+      %span.count= current_user.assigned_merge_requests.opened.count
   = nav_link(controller: :help) do
     = link_to "Help", help_path
 
index 2f051ce..c1a3a9e 100644 (file)
@@ -1,6 +1,18 @@
 = form_tag filter_path(entity), method: 'get' do
   %fieldset
     %ul.nav.nav-pills.nav-stacked
+      %li{class: ("active" if params[:scope].blank?)}
+        = link_to filter_path(entity, scope: nil) do
+          Assigned to me
+      %li{class: ("active" if params[:scope] == 'authored')}
+        = link_to filter_path(entity, scope: 'authored') do
+          Authored by me
+      %li{class: ("active" if params[:scope] == 'all')}
+        = link_to filter_path(entity, scope: 'all') do
+          All
+
+  %fieldset
+    %ul.nav.nav-pills.nav-stacked
       %li{class: ("active" if params[:status].blank?)}
         = link_to filter_path(entity, status: nil) do
           Open