debian-mirror-gitlab/app/helpers/milestones_helper.rb

50 lines
1.4 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
module MilestonesHelper
def milestones_filter_path(opts = {})
if @project
namespace_project_milestones_path(@project.namespace, @project, opts)
elsif @group
group_milestones_path(@group, opts)
else
dashboard_milestones_path(opts)
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-12-23 02:04:40 +05:30
epoch = DateTime.parse('1970-01-01')
2015-11-26 14:37:03 +05:30
grouped_milestones = GlobalMilestone.build_collection(milestones)
2015-12-23 02:04:40 +05:30
grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
2015-09-11 14:41:01 +05:30
grouped_milestones.unshift(Milestone::None)
2015-10-24 18:46:33 +05:30
grouped_milestones.unshift(Milestone::Any)
2015-09-11 14:41:01 +05:30
2015-10-24 18:46:33 +05:30
options_from_collection_for_select(grouped_milestones, 'name', 'title', params[:milestone_title])
2015-04-26 12:48:37 +05:30
end
2016-04-02 18:10:28 +05:30
def milestone_remaining_days(milestone)
if milestone.expired?
content_tag(:strong, 'expired')
elsif milestone.due_date
days = milestone.remaining_days
content = content_tag(:strong, days)
content << " #{'day'.pluralize(days)} remaining"
end
end
2015-04-26 12:48:37 +05:30
end