Module: MilestonesHelper

Defined in:
app/helpers/milestones_helper.rb

Instance Method Summary collapse

Instance Method Details

#milestone_issues_by_label_count(milestone, label, state:) ⇒ Object


34
35
36
# File 'app/helpers/milestones_helper.rb', line 34

def milestone_issues_by_label_count(milestone, label, state:)
  milestone.issues.with_label(label.title).send(state).size
end

#milestone_progress_bar(milestone) ⇒ Object


38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/milestones_helper.rb', line 38

def milestone_progress_bar(milestone)
  options = {
    class: 'progress-bar progress-bar-success',
    style: "width: #{milestone.percent_complete(current_user)}%;"
  }

   :div, class: 'progress' do
     :div, nil, options
  end
end

#milestone_remaining_days(milestone) ⇒ Object


57
58
59
60
61
62
63
64
65
# File 'app/helpers/milestones_helper.rb', line 57

def milestone_remaining_days(milestone)
  if milestone.expired?
    (:strong, 'expired')
  elsif milestone.due_date
    days    = milestone.remaining_days
    content = (:strong, days)
    content << " #{'day'.pluralize(days)} remaining"
  end
end

#milestones_browse_issuables_path(milestone, type:) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/milestones_helper.rb', line 22

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

#milestones_filter_dropdown_pathObject


49
50
51
52
53
54
55
# File 'app/helpers/milestones_helper.rb', line 49

def milestones_filter_dropdown_path
  if @project
    namespace_project_milestones_path(@project.namespace, @project, :json)
  else
    dashboard_milestones_path(:json)
  end
end

#milestones_filter_path(opts = {}) ⇒ Object


2
3
4
5
6
7
8
9
10
# File 'app/helpers/milestones_helper.rb', line 2

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

#milestones_label_path(opts = {}) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'app/helpers/milestones_helper.rb', line 12

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