2015-01-06 15:32:04 -05:00
|
|
|
module MilestonesHelper
|
|
|
|
def milestones_filter_path(opts = {})
|
|
|
|
if @project
|
2015-01-24 13:02:58 -05:00
|
|
|
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
|
2015-03-09 18:20:32 -04:00
|
|
|
|
2016-03-06 23:07:19 -05:00
|
|
|
def milestones_label_path(opts = {})
|
|
|
|
if @project
|
|
|
|
namespace_project_issues_path(@project.namespace, @project, opts)
|
|
|
|
elsif @group
|
|
|
|
issues_group_path(@group, opts)
|
|
|
|
else
|
|
|
|
issues_dashboard_path(opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def milestones_browse_issuables_path(milestone, type:)
|
|
|
|
opts = { milestone_title: milestone.title }
|
|
|
|
|
|
|
|
if @project
|
|
|
|
polymorphic_path([@project.namespace.becomes(Namespace), @project, type], opts)
|
|
|
|
elsif @group
|
|
|
|
polymorphic_url([type, @group], opts)
|
|
|
|
else
|
|
|
|
polymorphic_url([type, :dashboard], opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def milestone_issues_by_label_count(milestone, label, state:)
|
|
|
|
milestone.issues.with_label(label.title).send(state).size
|
|
|
|
end
|
|
|
|
|
2015-03-09 18:20:32 -04:00
|
|
|
def milestone_progress_bar(milestone)
|
|
|
|
options = {
|
|
|
|
class: 'progress-bar progress-bar-success',
|
2016-03-17 16:59:30 -04:00
|
|
|
style: "width: #{milestone.percent_complete(current_user)}%;"
|
2015-03-09 18:20:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
content_tag :div, class: 'progress' do
|
|
|
|
content_tag :div, nil, options
|
|
|
|
end
|
|
|
|
end
|
2015-03-26 22:13:49 -04:00
|
|
|
|
2016-03-16 15:14:31 -04:00
|
|
|
def milestones_filter_dropdown_path
|
|
|
|
if @project
|
|
|
|
namespace_project_milestones_path(@project.namespace, @project, :json)
|
|
|
|
else
|
2016-03-22 14:19:53 -04:00
|
|
|
dashboard_milestones_path(:json)
|
2016-03-16 15:14:31 -04:00
|
|
|
end
|
2015-03-26 22:13:49 -04:00
|
|
|
end
|
2016-02-25 15:23:34 -05:00
|
|
|
|
|
|
|
def milestone_remaining_days(milestone)
|
2016-03-01 19:39:58 -05:00
|
|
|
if milestone.expired?
|
2016-02-25 15:23:34 -05:00
|
|
|
content_tag(:strong, 'expired')
|
2016-03-01 19:39:58 -05:00
|
|
|
elsif milestone.due_date
|
|
|
|
days = milestone.remaining_days
|
2016-02-25 15:23:34 -05:00
|
|
|
content = content_tag(:strong, days)
|
|
|
|
content << " #{'day'.pluralize(days)} remaining"
|
|
|
|
end
|
|
|
|
end
|
2015-01-06 15:32:04 -05:00
|
|
|
end
|