#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
#
# Copyright (C) 2012-2013 the OpenProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
module IssuesHelper
include ApplicationHelper
def issue_list(issues, &block)
ancestors = []
issues.each do |issue|
while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
ancestors.pop
end
yield issue, ancestors.size
ancestors << issue unless issue.leaf?
end
end
# Renders a HTML/CSS tooltip
#
# To use, a trigger div is needed. This is a div with the class of "tooltip"
# that contains this method wrapped in a span with the class of "tip"
#
#
<%= link_to_issue(issue) %>
# <%= render_issue_tooltip(issue) %>
#
#
def render_issue_tooltip(issue)
@cached_label_status ||= Issue.human_attribute_name(:status)
@cached_label_start_date ||= Issue.human_attribute_name(:start_date)
@cached_label_due_date ||= Issue.human_attribute_name(:due_date)
@cached_label_assigned_to ||= Issue.human_attribute_name(:assigned_to)
@cached_label_priority ||= Issue.human_attribute_name(:priority)
@cached_label_project ||= Issue.human_attribute_name(:project)
(link_to_issue(issue) + "
" +
"#{@cached_label_project}: #{link_to_project(issue.project)}
" +
"#{@cached_label_status}: #{h(issue.status.name)}
" +
"#{@cached_label_start_date}: #{format_date(issue.start_date)}
" +
"#{@cached_label_due_date}: #{format_date(issue.due_date)}
" +
"#{@cached_label_assigned_to}: #{h(issue.assigned_to)}
" +
"#{@cached_label_priority}: #{h(issue.priority.name)}").html_safe
end
# TODO: deprecate and/or remove
def render_issue_subject_with_tree(issue)
s = ''
ancestors = issue.root? ? [] : issue.ancestors.all
ancestors.each do |ancestor|
s << '' + content_tag('h2', link_to_issue(ancestor))
end
s << '
' + content_tag('h2', h(issue.subject))
s << '
' * (ancestors.size + 1)
s
end
def render_descendants_tree(issue)
s = '