diff options
author | Robert Speicher <robert@gitlab.com> | 2016-03-19 00:40:46 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-03-19 00:40:46 +0300 |
commit | 18fc7c66f4455e757593a60e02a6306decef5a47 (patch) | |
tree | c316a0a7b67a1f46d9e3c59cf8b699989dfebba7 /app | |
parent | c790107854658a37d97b9a1c9066338eb12b06bf (diff) | |
parent | 733ae58798f6736af156e94b6906ac9c0b76fa3d (diff) |
Merge branch 'fix/14418' into 'master'
Dedupe labels in labels selector in Dashboard pages
Fixes #14418.
See merge request !3311
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/dashboard_controller.rb | 11 | ||||
-rw-r--r-- | app/helpers/labels_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/milestones_helper.rb | 13 |
3 files changed, 9 insertions, 23 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 36986d9a18d..b538c7d1608 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -21,17 +21,24 @@ class DashboardController < Dashboard::ApplicationController end def labels + labels = Label.where(project_id: @projects).select(:title, :color).uniq(:title) + respond_to do |format| format.json do - render json: view_context.projects_labels_options + render json: labels end end end def milestones + milestones = Milestone.where(project_id: @projects).active + epoch = DateTime.parse('1970-01-01') + grouped_milestones = GlobalMilestone.build_collection(milestones) + grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date } + respond_to do |format| format.json do - render json: view_context.projects_milestones_options + render json: grouped_milestones end end end diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 49f701e9bee..e238a7b4c26 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -109,14 +109,6 @@ module LabelsHelper end end - def projects_labels_options - if @project - @project.labels - else - Label.where(project_id: @projects) - end - end - def labels_filter_path if @project namespace_project_labels_path(@project.namespace, @project, :json) diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index de60be4eb25..c9d8787bd19 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -46,19 +46,6 @@ module MilestonesHelper end end - def projects_milestones_options - milestones = - if @project - @project.milestones - else - Milestone.where(project_id: @projects) - end.active - - epoch = DateTime.parse('1970-01-01') - grouped_milestones = GlobalMilestone.build_collection(milestones) - grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date } - end - def milestones_filter_dropdown_path if @project namespace_project_milestones_path(@project.namespace, @project, :json) |