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
layout 'group'
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 = case params[:status]
when 'all'; @group_milestones
......@@ -12,16 +11,17 @@ class Groups::MilestonesController < ApplicationController
end
end
def show
project_milestones = Milestone.where(project_id: group.projects)
@group_milestones = Milestones::GroupService.new(project_milestones).milestone(title)
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 = Milestones::GroupService.new(project_milestones).milestone(title)
@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
@group_milestones.each do |milestone|
Milestones::UpdateService.new(milestone.project, current_user, params[:milestone]).execute(milestone)
end
respond_to do |format|
......@@ -38,6 +38,10 @@ class Groups::MilestonesController < ApplicationController
@group ||= Group.find_by(path: params[:group_id])
end
def title
params[:id].gsub("-", ".")
end
def status(state)
@group_milestones.map{ |milestone| next if milestone.state != state; milestone }.compact
end
......
......@@ -8,5 +8,13 @@ module Milestones
@project_milestones.map{ |title, milestone| GroupMilestone.new(title, milestone) }
end
def milestone(title)
if title
@project_milestones[title]
else
nil
end
end
end
end
......@@ -30,7 +30,7 @@
- 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
= link_to_gfm truncate(milestone.title, length: 100), group_milestone_path(@group, safe_title)
%div
%div
= 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