debian-mirror-gitlab/app/controllers/dashboard/milestones_controller.rb

35 lines
855 B
Ruby
Raw Normal View History

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