Module: AdditionalTagsIssuesHelper

Defined in:
app/helpers/additional_tags_issues_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_api_custom_values(custom_values, api) ⇒ Object

Hacked render_api_custom_values to add plugin values to issue api



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/additional_tags_issues_helper.rb', line 5

def render_api_custom_values(custom_values, api)
  rc = super

  if @issue.present? &&
     (defined?(controller_name) && controller_name == 'issues' && action_name == 'show' || !defined?(controller_name)) &&
     AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, @project)

    api.array :tags do
      # support tags, which are not saved to database
      if @issue.tag_list.present?
        if @issue.tags.present? && @issue.tags.map(&:name) == @issue.tag_list
          @issue.tags.each do |tag|
            api.tag id: tag.id, name: tag.name
          end
        else
          @issue.tag_list.each do |tag_name|
            # there is no id for unsaved tags
            api.tag name: tag_name
          end
        end
      end
    end
  end

  if @time_entry.present? &&
     (defined?(controller_name) && controller_name == 'timelog' && action_name == 'show' || !defined?(controller_name)) &&
     AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, @project)
    api.array :issue_tags do
      @time_entry.issue_tags.each do |tag|
        api.tag id: tag.id, name: tag.name
      end
    end
  end

  rc
end

#render_sidebar_tagsObject



56
57
58
59
60
61
62
# File 'app/helpers/additional_tags_issues_helper.rb', line 56

def render_sidebar_tags
  options = { filter: AdditionalTags.setting?(:open_issues_only) ? { field: :status_id, operator: 'o' } : nil,
              project: @project }

  options[:tag_action] = 'show' if %w[gantts calendars].include? controller_name
  render_tags_list sidebar_tags, **options
end


42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/helpers/additional_tags_issues_helper.rb', line 42

def sidebar_tags
  # we do not want tags on issue import
  return if controller_name == 'imports'

  unless @sidebar_tags
    @sidebar_tags = []
    if AdditionalTags.show_sidebar_tags?
      @sidebar_tags = Issue.available_tags project: @project,
                                           open_issues_only: AdditionalTags.setting?(:open_issues_only)
    end
  end
  @sidebar_tags.to_a
end