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