Commit b6425f33 authored by Marin Jankovski's avatar Marin Jankovski

Get one group milestone based on milestone title.

parent f0af302c
...@@ -2,8 +2,7 @@ class Groups::MilestonesController < ApplicationController ...@@ -2,8 +2,7 @@ class Groups::MilestonesController < ApplicationController
layout 'group' layout 'group'
def index def index
@group = group project_milestones = Milestone.where(project_id: group.projects)
project_milestones = Milestone.where(project_id: @group.projects)
@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
...@@ -12,16 +11,17 @@ class Groups::MilestonesController < ApplicationController ...@@ -12,16 +11,17 @@ class Groups::MilestonesController < ApplicationController
end end
end end
def show
project_milestones = Milestone.where(project_id: group.projects)
@group_milestones = Milestones::GroupService.new(project_milestones).milestone(title)
end
def update def update
project_milestones = Milestone.where(project_id: group.projects) project_milestones = Milestone.where(project_id: group.projects)
@group_milestones = Milestones::GroupService.new(project_milestones).execute @group_milestones = Milestones::GroupService.new(project_milestones).milestone(title)
title = params[:id].gsub("-", ".")
@group_milestones.each do |group_milestone| @group_milestones.each do |milestone|
next unless group_milestone.title == title Milestones::UpdateService.new(milestone.project, current_user, params[:milestone]).execute(milestone)
group_milestone.milestones.each do |milestone|
Milestones::UpdateService.new(milestone.project, current_user, params[:milestone]).execute(milestone)
end
end end
respond_to do |format| respond_to do |format|
...@@ -38,6 +38,10 @@ class Groups::MilestonesController < ApplicationController ...@@ -38,6 +38,10 @@ class Groups::MilestonesController < ApplicationController
@group ||= Group.find_by(path: params[:group_id]) @group ||= Group.find_by(path: params[:group_id])
end end
def title
params[:id].gsub("-", ".")
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
......
...@@ -8,5 +8,13 @@ module Milestones ...@@ -8,5 +8,13 @@ module Milestones
@project_milestones.map{ |title, milestone| GroupMilestone.new(title, milestone) } @project_milestones.map{ |title, milestone| GroupMilestone.new(title, milestone) }
end end
def milestone(title)
if title
@project_milestones[title]
else
nil
end
end
end end
end end
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- else - else
= link_to 'Close Milestone', group_milestone_path(@group, safe_title, milestone: {state_event: :close }), method: :put, class: "btn btn-small btn-remove" = 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), group_milestone_path(@group, safe_title)
%div %div
%div %div
= link_to root_path do = link_to root_path do
......
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