Skip to content
Snippets Groups Projects
Commit c38b9a2f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Filter projects on dashboard

parent a03f3189
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -100,3 +100,17 @@ input[type='search'].search-text-input {
}
 
fieldset legend { font-size: 17px; }
ul.nav.nav-projects-tabs {
@extend .nav-tabs;
padding-left: 8px;
li {
a {
padding: 4px 20px;
margin-top: 2px;
border-color: #DDD;
}
}
}
Loading
Loading
@@ -7,6 +7,15 @@ class DashboardController < ApplicationController
def index
@groups = current_user.authorized_groups
 
@projects = case params[:scope]
when 'personal' then
@projects.personal(current_user)
when 'joined' then
@projects.joined(current_user)
else
@projects
end
@projects = @projects.page(params[:page]).per(30)
 
@events = Event.in_projects(current_user.project_ids)
Loading
Loading
Loading
Loading
@@ -84,4 +84,17 @@ module TabHelper
'active'
end
end
# Use nav_tab for save controller/action but different params
def nav_tab key, value, &block
o = {}
o[:class] = ""
o[:class] << " active" if params[key] == value
if block_given?
content_tag(:li, capture(&block), o)
else
content_tag(:li, nil, o)
end
end
end
Loading
Loading
@@ -74,6 +74,8 @@ class Project < ActiveRecord::Base
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
 
class << self
def authorized_for user
Loading
Loading
Loading
Loading
@@ -8,6 +8,14 @@
= link_to new_project_path, class: "btn very_small info" do
%i.icon-plus
New Project
%ul.nav.nav-projects-tabs
= nav_tab :scope, nil do
= link_to "All", dashboard_path
= nav_tab :scope, 'personal' do
= link_to "Personal", dashboard_path(scope: 'personal')
= nav_tab :scope, 'joined' do
= link_to "Joined", dashboard_path(scope: 'joined')
%ul.unstyled
- projects.each do |project|
%li.wll
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment