Commit abff03996ad59e25be52d51605f6ede698363ecb

Authored by Dmitriy Zaporozhets
1 parent de12eba2

Fix project labels scope

app/controllers/dashboard_controller.rb
... ... @@ -37,6 +37,8 @@ class DashboardController < ApplicationController
37 37 @projects = @projects.tagged_with(params[:label]) if params[:label].present?
38 38 @projects = @projects.search(params[:search]) if params[:search].present?
39 39 @projects = @projects.page(params[:page]).per(30)
  40 +
  41 + @labels = Project.where(id: @projects.map(&:id)).tags_on(:labels)
40 42 end
41 43  
42 44 # Get authored or assigned open merge requests
... ...
app/helpers/projects_helper.rb
... ... @@ -3,10 +3,6 @@ module ProjectsHelper
3 3 "You are going to remove #{user.name} from #{project.name} project team. Are you sure?"
4 4 end
5 5  
6   - def projects_labels
7   - Project.tag_counts_on(:labels).map(&:name)
8   - end
9   -
10 6 def link_to_project project
11 7 link_to project do
12 8 title = content_tag(:strong, project.name)
... ...
app/views/dashboard/projects.html.haml
... ... @@ -22,11 +22,11 @@
22 22  
23 23 %p.light Filter by label:
24 24 %ul.bordered-list
25   - - projects_labels.each do |label|
26   - %li{ class: (label == params[:label]) ? 'active' : 'light' }
27   - = link_to projects_dashboard_path(scope: params[:scope], label: label) do
  25 + - @labels.each do |label|
  26 + %li{ class: (label.name == params[:label]) ? 'active' : 'light' }
  27 + = link_to projects_dashboard_path(scope: params[:scope], label: label.name) do
28 28 %i.icon-tag
29   - = label
  29 + = label.name
30 30  
31 31  
32 32 .span9
... ...