Close and reopen group milestones.
This commit is contained in:
parent
4ca8a175a2
commit
f0af302c83
3 changed files with 38 additions and 11 deletions
|
@ -2,9 +2,8 @@ class Groups::MilestonesController < ApplicationController
|
|||
layout 'group'
|
||||
|
||||
def index
|
||||
@group = Group.find_by(path: params[:group_id])
|
||||
project_ids = @group.projects
|
||||
project_milestones = Milestone.where(project_id: project_ids)
|
||||
@group = group
|
||||
project_milestones = Milestone.where(project_id: @group.projects)
|
||||
@group_milestones = Milestones::GroupService.new(project_milestones).execute
|
||||
@group_milestones = case params[:status]
|
||||
when 'all'; @group_milestones
|
||||
|
@ -13,8 +12,32 @@ class Groups::MilestonesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def update
|
||||
project_milestones = Milestone.where(project_id: group.projects)
|
||||
@group_milestones = Milestones::GroupService.new(project_milestones).execute
|
||||
title = params[:id].gsub("-", ".")
|
||||
|
||||
@group_milestones.each do |group_milestone|
|
||||
next unless group_milestone.title == title
|
||||
group_milestone.milestones.each do |milestone|
|
||||
Milestones::UpdateService.new(milestone.project, current_user, params[:milestone]).execute(milestone)
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html do
|
||||
redirect_to group_milestones_path(group)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def group
|
||||
@group ||= Group.find_by(path: params[:group_id])
|
||||
end
|
||||
|
||||
def status(state)
|
||||
@group_milestones.map{ |milestone| next if milestone.state != state; milestone }.compact
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ class GroupMilestone
|
|||
@milestones
|
||||
end
|
||||
|
||||
def project_names
|
||||
milestones.map{ |milestone| milestone.project.name }
|
||||
def projects
|
||||
milestones.map{ |milestone| milestone.project }
|
||||
end
|
||||
|
||||
def issue_count
|
||||
|
@ -41,7 +41,8 @@ class GroupMilestone
|
|||
|
||||
def state
|
||||
state = milestones.map{ |milestone| milestone.state }
|
||||
if state.all?{ |milestone_state| milestone_state == 'active' }
|
||||
|
||||
if state.count("active") == state.size
|
||||
'active'
|
||||
else
|
||||
'closed'
|
||||
|
|
|
@ -23,9 +23,12 @@
|
|||
- else
|
||||
- @group_milestones.each do |milestone|
|
||||
%li{class: "milestone milestone-#{milestone.state == 'closed' ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) }
|
||||
- unless milestone.state == 'closed'
|
||||
.pull-right
|
||||
= link_to 'Close Milestone', root_path, method: :put, remote: true, class: "btn btn-small btn-remove"
|
||||
.pull-right
|
||||
- safe_title = milestone.title.gsub(".", "-")
|
||||
- if milestone.state == 'closed'
|
||||
= link_to 'Reopen Milestone', group_milestone_path(@group, safe_title, milestone: {state_event: :activate }), method: :put, class: "btn btn-small btn-grouped"
|
||||
- else
|
||||
= link_to 'Close Milestone', group_milestone_path(@group, safe_title, milestone: {state_event: :close }), method: :put, class: "btn btn-small btn-remove"
|
||||
%h4
|
||||
= link_to_gfm truncate(milestone.title, length: 100), root_path
|
||||
%div
|
||||
|
@ -41,6 +44,6 @@
|
|||
.progress-bar{style: "width: #{milestone.percent_complete}%;"}
|
||||
%div
|
||||
%br
|
||||
- milestone.project_names.each do |name|
|
||||
- milestone.projects.each do |project|
|
||||
%span.label.label-default
|
||||
= name
|
||||
= project.name
|
||||
|
|
Loading…
Reference in a new issue