Dedupe labels in labels selector in Dashboard pages
Also moved useless helper methods and directly to the DashboardController.
This commit is contained in:
parent
c790107854
commit
733ae58798
3 changed files with 9 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue