gitlab-org--gitlab-foss/app/helpers/milestones_helper.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2015-01-06 15:32:04 -05:00
module MilestonesHelper
def milestones_filter_path(opts = {})
if @project
namespace_project_milestones_path(@project.namespace, @project, opts)
2015-01-06 15:32:04 -05:00
elsif @group
group_milestones_path(@group, opts)
2015-03-03 10:19:37 -05:00
else
dashboard_milestones_path(opts)
2015-01-06 15:32:04 -05:00
end
end
def milestone_progress_bar(milestone)
options = {
class: 'progress-bar progress-bar-success',
style: "width: #{milestone.percent_complete}%;"
}
content_tag :div, class: 'progress' do
content_tag :div, nil, options
end
end
def projects_milestones_options
milestones =
if @project
@project.milestones
else
Milestone.where(project_id: @projects)
end.active
2015-11-30 15:47:44 -05:00
epoch = DateTime.parse('1970-01-01')
grouped_milestones = GlobalMilestone.build_collection(milestones)
2015-11-30 15:47:44 -05:00
grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
grouped_milestones.unshift(Milestone::None)
grouped_milestones.unshift(Milestone::Any)
options_from_collection_for_select(grouped_milestones, 'name', 'title', params[:milestone_title])
end
2015-01-06 15:32:04 -05:00
end