Commit f0af302c authored by Marin Jankovski's avatar Marin Jankovski

Close and reopen group milestones.

parent 4ca8a175
...@@ -2,9 +2,8 @@ class Groups::MilestonesController < ApplicationController ...@@ -2,9 +2,8 @@ class Groups::MilestonesController < ApplicationController
layout 'group' layout 'group'
def index def index
@group = Group.find_by(path: params[:group_id]) @group = group
project_ids = @group.projects project_milestones = Milestone.where(project_id: @group.projects)
project_milestones = Milestone.where(project_id: project_ids)
@group_milestones = Milestones::GroupService.new(project_milestones).execute @group_milestones = Milestones::GroupService.new(project_milestones).execute
@group_milestones = case params[:status] @group_milestones = case params[:status]
when 'all'; @group_milestones when 'all'; @group_milestones
...@@ -13,8 +12,32 @@ class Groups::MilestonesController < ApplicationController ...@@ -13,8 +12,32 @@ class Groups::MilestonesController < ApplicationController
end end
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 private
def group
@group ||= Group.find_by(path: params[:group_id])
end
def status(state) def status(state)
@group_milestones.map{ |milestone| next if milestone.state != state; milestone }.compact @group_milestones.map{ |milestone| next if milestone.state != state; milestone }.compact
end end
......
...@@ -13,8 +13,8 @@ class GroupMilestone ...@@ -13,8 +13,8 @@ class GroupMilestone
@milestones @milestones
end end
def project_names def projects
milestones.map{ |milestone| milestone.project.name } milestones.map{ |milestone| milestone.project }
end end
def issue_count def issue_count
...@@ -41,7 +41,8 @@ class GroupMilestone ...@@ -41,7 +41,8 @@ class GroupMilestone
def state def state
state = milestones.map{ |milestone| milestone.state } state = milestones.map{ |milestone| milestone.state }
if state.all?{ |milestone_state| milestone_state == 'active' }
if state.count("active") == state.size
'active' 'active'
else else
'closed' 'closed'
......
...@@ -23,9 +23,12 @@ ...@@ -23,9 +23,12 @@
- else - else
- @group_milestones.each do |milestone| - @group_milestones.each do |milestone|
%li{class: "milestone milestone-#{milestone.state == 'closed' ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) } %li{class: "milestone milestone-#{milestone.state == 'closed' ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) }
- unless milestone.state == 'closed'
.pull-right .pull-right
= link_to 'Close Milestone', root_path, method: :put, remote: true, class: "btn btn-small btn-remove" - 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 %h4
= link_to_gfm truncate(milestone.title, length: 100), root_path = link_to_gfm truncate(milestone.title, length: 100), root_path
%div %div
...@@ -41,6 +44,6 @@ ...@@ -41,6 +44,6 @@
.progress-bar{style: "width: #{milestone.percent_complete}%;"} .progress-bar{style: "width: #{milestone.percent_complete}%;"}
%div %div
%br %br
- milestone.project_names.each do |name| - milestone.projects.each do |project|
%span.label.label-default %span.label.label-default
= name = project.name
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment