This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

issues_helper.rb 2.22 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1
module IssuesHelper
2
3
4
5
  def project_issues_filter_path project, params = {}
    params[:f] ||= cookies['issue_filter']
    project_issues_path project, params
  end
6

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
7
8
  def issue_css_classes issue
    classes = "issue"
Andrew8xx8's avatar
Andrew8xx8 committed
9
    classes << " closed" if issue.closed?
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
10
11
12
    classes << " today" if issue.today?
    classes
  end
13

14
15
16
17
18
  # Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt>
  # to allow filtering issues by an unassigned User or Milestone
  def unassigned_filter
    # Milestone uses :title, Issue uses :name
    OpenStruct.new(id: 0, title: 'Unspecified', name: 'Unassigned')
19
  end
20
21
22
23
24
25

  def issues_filter
    {
      all: "all",
      closed: "closed",
      to_me: "assigned-to-me",
26
      by_me: "created-by-me",
27
28
29
      open: "open"
    }
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
30

31
32
33
  def issues_active_milestones
    @project.milestones.active.order("id desc").all
  end
34

35
36
37
38
  def url_for_project_issues
    return "" if @project.nil?

    if @project.used_default_issues_tracker?
39
      project_issues_filter_path(@project)
40
    else
41
      url = Gitlab.config.issues_tracker[@project.issues_tracker]["project_url"]
42
43
44
45
46
      url.gsub(':project_id', @project.id.to_s)
         .gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
    end
  end

47
48
49
50
51
52
  def url_for_new_issue
    return "" if @project.nil?

    if @project.used_default_issues_tracker?
      url = new_project_issue_path project_id: @project
    else
53
      url = Gitlab.config.issues_tracker[@project.issues_tracker]["new_issue_url"]
54
55
56
57
58
      url.gsub(':project_id', @project.id.to_s)
        .gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
    end
  end

59
  def url_for_issue(issue_id)
Andrew8xx8's avatar
Andrew8xx8 committed
60
61
    return "" if @project.nil?

62
    if @project.used_default_issues_tracker?
63
64
      url = project_issue_url project_id: @project, id: issue_id
    else
65
      url = Gitlab.config.issues_tracker[@project.issues_tracker]["issues_url"]
Andrew8xx8's avatar
Andrew8xx8 committed
66
67
68
      url.gsub(':id', issue_id.to_s)
        .gsub(':project_id', @project.id.to_s)
        .gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
69
70
71
72
    end
  end

  def title_for_issue(issue_id)
Andrew8xx8's avatar
Andrew8xx8 committed
73
74
    return "" if @project.nil?

75
    if @project.used_default_issues_tracker? && issue = @project.issues.where(id: issue_id).first
76
77
78
79
80
      issue.title
    else
      ""
    end
  end
gitlabhq's avatar
gitlabhq committed
81
end