diff options
author | Rémy Coutable <remy@rymai.me> | 2016-03-18 23:49:56 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-18 23:49:56 +0300 |
commit | 733ae58798f6736af156e94b6906ac9c0b76fa3d (patch) | |
tree | c316a0a7b67a1f46d9e3c59cf8b699989dfebba7 /app/controllers/dashboard_controller.rb | |
parent | c790107854658a37d97b9a1c9066338eb12b06bf (diff) |
Dedupe labels in labels selector in Dashboard pages
Also moved useless helper methods and directly to the
DashboardController.
Diffstat (limited to 'app/controllers/dashboard_controller.rb')
-rw-r--r-- | app/controllers/dashboard_controller.rb | 11 |
1 files changed, 9 insertions, 2 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 |