2018-09-23 19:44:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-30 17:06:18 +00:00
|
|
|
class Dashboard::MilestonesController < Dashboard::ApplicationController
|
2015-11-13 18:20:48 +00:00
|
|
|
before_action :projects
|
2018-10-16 12:52:08 +00:00
|
|
|
before_action :groups, only: :index
|
2015-03-03 15:19:37 +00:00
|
|
|
|
2020-10-02 12:09:03 +00:00
|
|
|
feature_category :issue_tracking
|
|
|
|
|
2015-03-03 15:19:37 +00:00
|
|
|
def index
|
2016-03-22 18:19:53 +00:00
|
|
|
respond_to do |format|
|
2016-03-23 08:09:58 +00:00
|
|
|
format.html do
|
2020-05-28 12:08:10 +00:00
|
|
|
@milestone_states = Milestone.states_count(@projects.select(:id), groups.select(:id))
|
|
|
|
@milestones = milestones.page(params[:page])
|
2016-03-23 08:09:58 +00:00
|
|
|
end
|
2016-03-22 18:19:53 +00:00
|
|
|
format.json do
|
2020-05-28 12:08:10 +00:00
|
|
|
render json: milestones.to_json(only: [:id, :title], methods: :name)
|
2016-03-22 18:19:53 +00:00
|
|
|
end
|
|
|
|
end
|
2015-03-03 15:19:37 +00:00
|
|
|
end
|
|
|
|
|
2017-01-06 12:47:18 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def milestones
|
2020-05-28 12:08:10 +00:00
|
|
|
MilestonesFinder.new(search_params).execute
|
2017-01-06 12:47:18 +00:00
|
|
|
end
|
2018-10-16 12:52:08 +00:00
|
|
|
|
|
|
|
def groups
|
2019-02-14 05:45:30 +00:00
|
|
|
@groups ||= GroupsFinder.new(current_user, all_available: false).execute
|
2018-10-16 12:52:08 +00:00
|
|
|
end
|
2020-05-28 12:08:10 +00:00
|
|
|
|
|
|
|
def search_params
|
|
|
|
params.permit(:state, :search_title).merge(group_ids: groups, project_ids: projects)
|
|
|
|
end
|
2015-03-03 15:19:37 +00:00
|
|
|
end
|