Commit abff03996ad59e25be52d51605f6ede698363ecb
1 parent
de12eba2
Exists in
master
and in
4 other branches
Fix project labels scope
Showing
3 changed files
with
6 additions
and
8 deletions
Show diff stats
app/controllers/dashboard_controller.rb
| @@ -37,6 +37,8 @@ class DashboardController < ApplicationController | @@ -37,6 +37,8 @@ class DashboardController < ApplicationController | ||
| 37 | @projects = @projects.tagged_with(params[:label]) if params[:label].present? | 37 | @projects = @projects.tagged_with(params[:label]) if params[:label].present? |
| 38 | @projects = @projects.search(params[:search]) if params[:search].present? | 38 | @projects = @projects.search(params[:search]) if params[:search].present? |
| 39 | @projects = @projects.page(params[:page]).per(30) | 39 | @projects = @projects.page(params[:page]).per(30) |
| 40 | + | ||
| 41 | + @labels = Project.where(id: @projects.map(&:id)).tags_on(:labels) | ||
| 40 | end | 42 | end |
| 41 | 43 | ||
| 42 | # Get authored or assigned open merge requests | 44 | # Get authored or assigned open merge requests |
app/helpers/projects_helper.rb
| @@ -3,10 +3,6 @@ module ProjectsHelper | @@ -3,10 +3,6 @@ module ProjectsHelper | ||
| 3 | "You are going to remove #{user.name} from #{project.name} project team. Are you sure?" | 3 | "You are going to remove #{user.name} from #{project.name} project team. Are you sure?" |
| 4 | end | 4 | end |
| 5 | 5 | ||
| 6 | - def projects_labels | ||
| 7 | - Project.tag_counts_on(:labels).map(&:name) | ||
| 8 | - end | ||
| 9 | - | ||
| 10 | def link_to_project project | 6 | def link_to_project project |
| 11 | link_to project do | 7 | link_to project do |
| 12 | title = content_tag(:strong, project.name) | 8 | title = content_tag(:strong, project.name) |
app/views/dashboard/projects.html.haml
| @@ -22,11 +22,11 @@ | @@ -22,11 +22,11 @@ | ||
| 22 | 22 | ||
| 23 | %p.light Filter by label: | 23 | %p.light Filter by label: |
| 24 | %ul.bordered-list | 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 | %i.icon-tag | 28 | %i.icon-tag |
| 29 | - = label | 29 | + = label.name |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | .span9 | 32 | .span9 |