Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -19,7 +21,7 @@ module Redmine
|
|||
module Helpers
|
||||
# Simple class to handle gantt chart data
|
||||
class Gantt
|
||||
class MaxLinesLimitReached < Exception
|
||||
class MaxLinesLimitReached < StandardError
|
||||
end
|
||||
|
||||
include ERB::Util
|
||||
|
@ -32,8 +34,10 @@ module Redmine
|
|||
IssueRelation::TYPE_PRECEDES => { :landscape_margin => 20, :color => '#628FEA' }
|
||||
}.freeze
|
||||
|
||||
# :nodoc:
|
||||
UNAVAILABLE_COLUMNS = [:tracker, :id, :subject]
|
||||
|
||||
# Some utility methods for the PDF export
|
||||
# @private
|
||||
class PDF
|
||||
MaxCharactorsForSubject = 45
|
||||
TotalWidth = 280
|
||||
|
@ -65,17 +69,19 @@ module Redmine
|
|||
zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
|
||||
@zoom = (zoom > 0 && zoom < 5) ? zoom : 2
|
||||
months = (options[:months] || User.current.pref[:gantt_months]).to_i
|
||||
@months = (months > 0 && months < 25) ? months : 6
|
||||
@months = (months > 0 && months < Setting.gantt_months_limit.to_i + 1) ? months : 6
|
||||
# Save gantt parameters as user preference (zoom and months count)
|
||||
if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] ||
|
||||
@months != User.current.pref[:gantt_months]))
|
||||
if User.current.logged? &&
|
||||
(@zoom != User.current.pref[:gantt_zoom] ||
|
||||
@months != User.current.pref[:gantt_months])
|
||||
User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
|
||||
User.current.preference.save
|
||||
end
|
||||
@date_from = Date.civil(@year_from, @month_from, 1)
|
||||
@date_to = (@date_from >> @months) - 1
|
||||
@subjects = ''
|
||||
@lines = ''
|
||||
@subjects = +''
|
||||
@lines = +''
|
||||
@columns ||= {}
|
||||
@number_of_rows = nil
|
||||
@truncated = false
|
||||
if options.has_key?(:max_rows)
|
||||
|
@ -135,11 +141,17 @@ module Redmine
|
|||
@lines
|
||||
end
|
||||
|
||||
# Renders the selected column of the Gantt chart, the right side of subjects.
|
||||
def selected_column_content(options={})
|
||||
render(options.merge(:only => :selected_columns)) unless @columns.has_key?(options[:column].name)
|
||||
@columns[options[:column].name]
|
||||
end
|
||||
|
||||
# Returns issues that will be rendered
|
||||
def issues
|
||||
@issues ||= @query.issues(
|
||||
:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
|
||||
:order => "#{Project.table_name}.lft ASC, #{Issue.table_name}.id ASC",
|
||||
:order => ["#{Project.table_name}.lft ASC", "#{Issue.table_name}.id ASC"],
|
||||
:limit => @max_rows
|
||||
)
|
||||
end
|
||||
|
@ -196,8 +208,9 @@ module Redmine
|
|||
:indent_increment => 20, :render => :subject,
|
||||
:format => :html}.merge(options)
|
||||
indent = options[:indent] || 4
|
||||
@subjects = '' unless options[:only] == :lines
|
||||
@lines = '' unless options[:only] == :subjects
|
||||
@subjects = +'' unless options[:only] == :lines || options[:only] == :selected_columns
|
||||
@lines = +'' unless options[:only] == :subjects || options[:only] == :selected_columns
|
||||
@columns[options[:column].name] = +'' if options[:only] == :selected_columns && @columns.has_key?(options[:column]) == false
|
||||
@number_of_rows = 0
|
||||
begin
|
||||
Project.project_tree(projects) do |project, level|
|
||||
|
@ -207,8 +220,8 @@ module Redmine
|
|||
rescue MaxLinesLimitReached
|
||||
@truncated = true
|
||||
end
|
||||
@subjects_rendered = true unless options[:only] == :lines
|
||||
@lines_rendered = true unless options[:only] == :subjects
|
||||
@subjects_rendered = true unless options[:only] == :lines || options[:only] == :selected_columns
|
||||
@lines_rendered = true unless options[:only] == :subjects || options[:only] == :selected_columns
|
||||
render_end(options)
|
||||
end
|
||||
|
||||
|
@ -254,8 +267,9 @@ module Redmine
|
|||
|
||||
def render_object_row(object, options)
|
||||
class_name = object.class.name.downcase
|
||||
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines
|
||||
send("line_for_#{class_name}", object, options) unless options[:only] == :subjects
|
||||
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines || options[:only] == :selected_columns
|
||||
send("line_for_#{class_name}", object, options) unless options[:only] == :subjects || options[:only] == :selected_columns
|
||||
column_content_for_issue(object, options) if options[:only] == :selected_columns && options[:column].present? && object.is_a?(Issue)
|
||||
options[:top] += options[:top_increment]
|
||||
@number_of_rows += 1
|
||||
if @max_rows && @number_of_rows >= @max_rows
|
||||
|
@ -301,9 +315,9 @@ module Redmine
|
|||
def line_for_version(version, options)
|
||||
# Skip versions that don't have a start_date
|
||||
if version.is_a?(Version) && version.due_date && version.start_date
|
||||
label = "#{h(version)} #{h(version.completed_percent.to_f.round)}%"
|
||||
label = "#{h(version)} #{h(version.visible_fixed_issues.completed_percent.to_f.round)}%"
|
||||
label = h("#{version.project} -") + label unless @project && @project == version.project
|
||||
line(version.start_date, version.due_date, version.completed_percent, true, label, options, version)
|
||||
line(version.start_date, version.due_date, version.visible_fixed_issues.completed_percent, true, label, options, version)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -323,6 +337,17 @@ module Redmine
|
|||
end
|
||||
end
|
||||
|
||||
def column_content_for_issue(issue, options)
|
||||
if options[:format] == :html
|
||||
data_options = {}
|
||||
data_options[:collapse_expand] = "issue-#{issue.id}"
|
||||
style = "position: absolute;top: #{options[:top]}px; font-size: 0.8em;"
|
||||
content = view.content_tag(:div, view.column_content(options[:column], issue), :style => style, :class => "issue_#{options[:column].name}", :id => "#{options[:column].name}_issue_#{issue.id}", :data => data_options)
|
||||
@columns[options[:column].name] << content if @columns.has_key?(options[:column].name)
|
||||
content
|
||||
end
|
||||
end
|
||||
|
||||
def subject(label, options, object=nil)
|
||||
send "#{options[:format]}_subject", options, label, object
|
||||
end
|
||||
|
@ -335,7 +360,7 @@ module Redmine
|
|||
end
|
||||
|
||||
# Generates a gantt image
|
||||
# Only defined if RMagick is avalaible
|
||||
# Only defined if MiniMagick is avalaible
|
||||
def to_image(format='PNG')
|
||||
date_to = (@date_from >> @months) - 1
|
||||
show_weeks = @zoom > 1
|
||||
|
@ -348,98 +373,123 @@ module Redmine
|
|||
g_height = 20 * number_of_rows + 30
|
||||
headers_height = (show_weeks ? 2 * header_height : header_height)
|
||||
height = g_height + headers_height
|
||||
imgl = Magick::ImageList.new
|
||||
imgl.new_image(subject_width + g_width + 1, height)
|
||||
gc = Magick::Draw.new
|
||||
gc.font = Redmine::Configuration['rmagick_font_path'] || ""
|
||||
# Subjects
|
||||
gc.stroke('transparent')
|
||||
subjects(:image => gc, :top => (headers_height + 20), :indent => 4, :format => :image)
|
||||
# Months headers
|
||||
month_f = @date_from
|
||||
left = subject_width
|
||||
@months.times do
|
||||
width = ((month_f >> 1) - month_f) * zoom
|
||||
gc.fill('white')
|
||||
gc.stroke('grey')
|
||||
gc.stroke_width(1)
|
||||
gc.rectangle(left, 0, left + width, height)
|
||||
gc.fill('black')
|
||||
# TODO: Remove rmagick_font_path in a later version
|
||||
Rails.logger.warn('rmagick_font_path option is deprecated. Use minimagick_font_path instead.') \
|
||||
unless Redmine::Configuration['rmagick_font_path'].nil?
|
||||
font_path = Redmine::Configuration['minimagick_font_path'].presence || Redmine::Configuration['rmagick_font_path'].presence
|
||||
img = MiniMagick::Image.create(".#{format}", false)
|
||||
MiniMagick::Tool::Convert.new do |gc|
|
||||
gc.size('%dx%d' % [subject_width + g_width + 1, height])
|
||||
gc.xc('white')
|
||||
gc.font(font_path) if font_path.present?
|
||||
# Subjects
|
||||
gc.stroke('transparent')
|
||||
gc.stroke_width(1)
|
||||
gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
|
||||
left = left + width
|
||||
month_f = month_f >> 1
|
||||
end
|
||||
# Weeks headers
|
||||
if show_weeks
|
||||
subjects(:image => gc, :top => (headers_height + 20), :indent => 4, :format => :image)
|
||||
# Months headers
|
||||
month_f = @date_from
|
||||
left = subject_width
|
||||
height = header_height
|
||||
if @date_from.cwday == 1
|
||||
# date_from is monday
|
||||
week_f = date_from
|
||||
else
|
||||
# find next monday after date_from
|
||||
week_f = @date_from + (7 - @date_from.cwday + 1)
|
||||
width = (7 - @date_from.cwday + 1) * zoom
|
||||
@months.times do
|
||||
width = ((month_f >> 1) - month_f) * zoom
|
||||
gc.fill('white')
|
||||
gc.stroke('grey')
|
||||
gc.stroke_width(1)
|
||||
gc.rectangle(left, header_height, left + width, 2 * header_height + g_height - 1)
|
||||
left = left + width
|
||||
end
|
||||
while week_f <= date_to
|
||||
width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
|
||||
gc.fill('white')
|
||||
gc.stroke('grey')
|
||||
gc.stroke_width(1)
|
||||
gc.rectangle(left.round, header_height, left.round + width, 2 * header_height + g_height - 1)
|
||||
gc.strokewidth(1)
|
||||
gc.draw('rectangle %d,%d %d,%d' % [
|
||||
left, 0, left + width, height
|
||||
])
|
||||
gc.fill('black')
|
||||
gc.stroke('transparent')
|
||||
gc.stroke_width(1)
|
||||
gc.text(left.round + 2, header_height + 14, week_f.cweek.to_s)
|
||||
gc.strokewidth(1)
|
||||
gc.draw('text %d,%d %s' % [
|
||||
left.round + 8, 14, Redmine::Utils::Shell.shell_quote("#{month_f.year}-#{month_f.month}")
|
||||
])
|
||||
left = left + width
|
||||
week_f = week_f + 7
|
||||
month_f = month_f >> 1
|
||||
end
|
||||
end
|
||||
# Days details (week-end in grey)
|
||||
if show_days
|
||||
left = subject_width
|
||||
height = g_height + header_height - 1
|
||||
wday = @date_from.cwday
|
||||
(date_to - @date_from + 1).to_i.times do
|
||||
width = zoom
|
||||
gc.fill(non_working_week_days.include?(wday) ? '#eee' : 'white')
|
||||
gc.stroke('#ddd')
|
||||
gc.stroke_width(1)
|
||||
gc.rectangle(left, 2 * header_height, left + width, 2 * header_height + g_height - 1)
|
||||
left = left + width
|
||||
wday = wday + 1
|
||||
wday = 1 if wday > 7
|
||||
# Weeks headers
|
||||
if show_weeks
|
||||
left = subject_width
|
||||
height = header_height
|
||||
if @date_from.cwday == 1
|
||||
# date_from is monday
|
||||
week_f = date_from
|
||||
else
|
||||
# find next monday after date_from
|
||||
week_f = @date_from + (7 - @date_from.cwday + 1)
|
||||
width = (7 - @date_from.cwday + 1) * zoom
|
||||
gc.fill('white')
|
||||
gc.stroke('grey')
|
||||
gc.strokewidth(1)
|
||||
gc.draw('rectangle %d,%d %d,%d' % [
|
||||
left, header_height, left + width, 2 * header_height + g_height - 1
|
||||
])
|
||||
left = left + width
|
||||
end
|
||||
while week_f <= date_to
|
||||
width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
|
||||
gc.fill('white')
|
||||
gc.stroke('grey')
|
||||
gc.strokewidth(1)
|
||||
gc.draw('rectangle %d,%d %d,%d' % [
|
||||
left.round, header_height, left.round + width, 2 * header_height + g_height - 1
|
||||
])
|
||||
gc.fill('black')
|
||||
gc.stroke('transparent')
|
||||
gc.strokewidth(1)
|
||||
gc.draw('text %d,%d %s' % [
|
||||
left.round + 2, header_height + 14, Redmine::Utils::Shell.shell_quote(week_f.cweek.to_s)
|
||||
])
|
||||
left = left + width
|
||||
week_f = week_f + 7
|
||||
end
|
||||
end
|
||||
# Days details (week-end in grey)
|
||||
if show_days
|
||||
left = subject_width
|
||||
height = g_height + header_height - 1
|
||||
wday = @date_from.cwday
|
||||
(date_to - @date_from + 1).to_i.times do
|
||||
width = zoom
|
||||
gc.fill(non_working_week_days.include?(wday) ? '#eee' : 'white')
|
||||
gc.stroke('#ddd')
|
||||
gc.strokewidth(1)
|
||||
gc.draw('rectangle %d,%d %d,%d' % [
|
||||
left, 2 * header_height, left + width, 2 * header_height + g_height - 1
|
||||
])
|
||||
left = left + width
|
||||
wday = wday + 1
|
||||
wday = 1 if wday > 7
|
||||
end
|
||||
end
|
||||
# border
|
||||
gc.fill('transparent')
|
||||
gc.stroke('grey')
|
||||
gc.strokewidth(1)
|
||||
gc.draw('rectangle %d,%d %d,%d' % [
|
||||
0, 0, subject_width + g_width, headers_height
|
||||
])
|
||||
gc.stroke('black')
|
||||
gc.draw('rectangle %d,%d %d,%d' % [
|
||||
0, 0, subject_width + g_width, g_height + headers_height - 1
|
||||
])
|
||||
# content
|
||||
top = headers_height + 20
|
||||
gc.stroke('transparent')
|
||||
lines(:image => gc, :top => top, :zoom => zoom,
|
||||
:subject_width => subject_width, :format => :image)
|
||||
# today red line
|
||||
if User.current.today >= @date_from and User.current.today <= date_to
|
||||
gc.stroke('red')
|
||||
x = (User.current.today - @date_from + 1) * zoom + subject_width
|
||||
gc.draw('line %g,%g %g,%g' % [
|
||||
x, headers_height, x, headers_height + g_height - 1
|
||||
])
|
||||
end
|
||||
gc << img.path
|
||||
end
|
||||
# border
|
||||
gc.fill('transparent')
|
||||
gc.stroke('grey')
|
||||
gc.stroke_width(1)
|
||||
gc.rectangle(0, 0, subject_width + g_width, headers_height)
|
||||
gc.stroke('black')
|
||||
gc.rectangle(0, 0, subject_width + g_width, g_height + headers_height - 1)
|
||||
# content
|
||||
top = headers_height + 20
|
||||
gc.stroke('transparent')
|
||||
lines(:image => gc, :top => top, :zoom => zoom,
|
||||
:subject_width => subject_width, :format => :image)
|
||||
# today red line
|
||||
if User.current.today >= @date_from and User.current.today <= date_to
|
||||
gc.stroke('red')
|
||||
x = (User.current.today - @date_from + 1) * zoom + subject_width
|
||||
gc.line(x, headers_height, x, headers_height + g_height - 1)
|
||||
end
|
||||
gc.draw(imgl)
|
||||
imgl.format = format
|
||||
imgl.to_blob
|
||||
end if Object.const_defined?(:Magick)
|
||||
img.to_blob
|
||||
ensure
|
||||
img.destroy! if img
|
||||
end if Object.const_defined?(:MiniMagick)
|
||||
|
||||
def to_pdf
|
||||
pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
|
||||
|
@ -581,7 +631,7 @@ module Redmine
|
|||
coords[:bar_start] = 0
|
||||
end
|
||||
if end_date < self.date_to
|
||||
coords[:end] = end_date - self.date_from
|
||||
coords[:end] = end_date - self.date_from + 1
|
||||
coords[:bar_end] = end_date - self.date_from + 1
|
||||
else
|
||||
coords[:bar_end] = self.date_to - self.date_from + 1
|
||||
|
@ -595,11 +645,11 @@ module Redmine
|
|||
coords[:bar_progress_end] = self.date_to - self.date_from + 1
|
||||
end
|
||||
end
|
||||
if progress_date < User.current.today
|
||||
late_date = [User.current.today, end_date].min
|
||||
if progress_date <= User.current.today
|
||||
late_date = [User.current.today, end_date].min + 1
|
||||
if late_date > self.date_from && late_date > start_date
|
||||
if late_date < self.date_to
|
||||
coords[:bar_late_end] = late_date - self.date_from + 1
|
||||
coords[:bar_late_end] = late_date - self.date_from
|
||||
else
|
||||
coords[:bar_late_end] = self.date_to - self.date_from + 1
|
||||
end
|
||||
|
@ -608,7 +658,7 @@ module Redmine
|
|||
end
|
||||
end
|
||||
# Transforms dates into pixels witdh
|
||||
coords.keys.each do |key|
|
||||
coords.each_key do |key|
|
||||
coords[key] = (coords[key] * zoom).floor
|
||||
end
|
||||
coords
|
||||
|
@ -618,23 +668,26 @@ module Redmine
|
|||
start_date + (end_date - start_date + 1) * (progress / 100.0)
|
||||
end
|
||||
|
||||
def self.sort_issues!(issues)
|
||||
issues.sort! {|a, b| sort_issue_logic(a) <=> sort_issue_logic(b)}
|
||||
end
|
||||
# Singleton class method is public
|
||||
class << self
|
||||
def sort_issues!(issues)
|
||||
issues.sort_by! {|issue| sort_issue_logic(issue)}
|
||||
end
|
||||
|
||||
def self.sort_issue_logic(issue)
|
||||
julian_date = Date.new()
|
||||
ancesters_start_date = []
|
||||
current_issue = issue
|
||||
begin
|
||||
ancesters_start_date.unshift([current_issue.start_date || julian_date, current_issue.id])
|
||||
current_issue = current_issue.parent
|
||||
end while (current_issue)
|
||||
ancesters_start_date
|
||||
end
|
||||
def sort_issue_logic(issue)
|
||||
julian_date = Date.new()
|
||||
ancesters_start_date = []
|
||||
current_issue = issue
|
||||
begin
|
||||
ancesters_start_date.unshift([current_issue.start_date || julian_date, current_issue.id])
|
||||
current_issue = current_issue.parent
|
||||
end while (current_issue)
|
||||
ancesters_start_date
|
||||
end
|
||||
|
||||
def self.sort_versions!(versions)
|
||||
versions.sort!
|
||||
def sort_versions!(versions)
|
||||
versions.sort!
|
||||
end
|
||||
end
|
||||
|
||||
def pdf_new_page?(options)
|
||||
|
@ -650,7 +703,7 @@ module Redmine
|
|||
case object
|
||||
when Issue
|
||||
issue = object
|
||||
css_classes = ''
|
||||
css_classes = +''
|
||||
css_classes << ' issue-overdue' if issue.overdue?
|
||||
css_classes << ' issue-behind-schedule' if issue.behind_schedule?
|
||||
css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
|
||||
|
@ -661,26 +714,21 @@ module Redmine
|
|||
css_classes << ' behind-start-date' if progress_date < self.date_from
|
||||
css_classes << ' over-end-date' if progress_date > self.date_to
|
||||
end
|
||||
s = "".html_safe
|
||||
if issue.assigned_to.present?
|
||||
assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
|
||||
s << view.avatar(issue.assigned_to,
|
||||
:class => 'gravatar icon-gravatar',
|
||||
:size => 13,
|
||||
:title => assigned_string).to_s.html_safe
|
||||
end
|
||||
s = (+"").html_safe
|
||||
s << view.assignee_avatar(issue.assigned_to, :size => 13, :class => 'icon-gravatar')
|
||||
s << view.link_to_issue(issue).html_safe
|
||||
s << view.content_tag(:input, nil, :type => 'checkbox', :name => 'ids[]', :value => issue.id, :style => 'display:none;', :class => 'toggle-selection')
|
||||
view.content_tag(:span, s, :class => css_classes).html_safe
|
||||
when Version
|
||||
version = object
|
||||
html_class = ""
|
||||
html_class = +""
|
||||
html_class << 'icon icon-package '
|
||||
html_class << (version.behind_schedule? ? 'version-behind-schedule' : '') << " "
|
||||
html_class << (version.overdue? ? 'version-overdue' : '')
|
||||
html_class << ' version-closed' unless version.open?
|
||||
if version.start_date && version.due_date && version.completed_percent
|
||||
if version.start_date && version.due_date && version.visible_fixed_issues.completed_percent
|
||||
progress_date = calc_progress_date(version.start_date,
|
||||
version.due_date, version.completed_percent)
|
||||
version.due_date, version.visible_fixed_issues.completed_percent)
|
||||
html_class << ' behind-start-date' if progress_date < self.date_from
|
||||
html_class << ' over-end-date' if progress_date > self.date_to
|
||||
end
|
||||
|
@ -688,7 +736,7 @@ module Redmine
|
|||
view.content_tag(:span, s, :class => html_class).html_safe
|
||||
when Project
|
||||
project = object
|
||||
html_class = ""
|
||||
html_class = +""
|
||||
html_class << 'icon icon-projects '
|
||||
html_class << (project.overdue? ? 'project-overdue' : '')
|
||||
s = view.link_to_project(project).html_safe
|
||||
|
@ -697,21 +745,43 @@ module Redmine
|
|||
end
|
||||
|
||||
def html_subject(params, subject, object)
|
||||
style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;"
|
||||
style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width]
|
||||
content = html_subject_content(object) || subject
|
||||
tag_options = {:style => style}
|
||||
tag_options = {}
|
||||
case object
|
||||
when Issue
|
||||
tag_options[:id] = "issue-#{object.id}"
|
||||
tag_options[:class] = "issue-subject"
|
||||
tag_options[:class] = "issue-subject hascontextmenu"
|
||||
tag_options[:title] = object.subject
|
||||
children = object.children & project_issues(object.project)
|
||||
has_children = children.present? && (children.collect(&:fixed_version).uniq & [object.fixed_version]).present?
|
||||
when Version
|
||||
tag_options[:id] = "version-#{object.id}"
|
||||
tag_options[:class] = "version-name"
|
||||
has_children = object.fixed_issues.exists?
|
||||
when Project
|
||||
tag_options[:class] = "project-name"
|
||||
has_children = object.issues.exists? || object.versions.exists?
|
||||
end
|
||||
if object
|
||||
tag_options[:data] = {
|
||||
:collapse_expand => {
|
||||
:top_increment => params[:top_increment],
|
||||
:obj_id => "#{object.class}-#{object.id}".downcase,
|
||||
},
|
||||
}
|
||||
end
|
||||
if has_children
|
||||
content = view.content_tag(:span, nil, :class => 'icon icon-expended expander') + content
|
||||
tag_options[:class] += ' open'
|
||||
else
|
||||
if params[:indent]
|
||||
params = params.dup
|
||||
params[:indent] += 12
|
||||
end
|
||||
end
|
||||
style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;"
|
||||
style += "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width]
|
||||
tag_options[:style] = style
|
||||
output = view.content_tag(:div, content, tag_options)
|
||||
@subjects << output
|
||||
output
|
||||
|
@ -725,7 +795,7 @@ module Redmine
|
|||
params[:pdf].RDMCell(params[:subject_width] - 15, 5,
|
||||
(" " * params[:indent]) +
|
||||
subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'),
|
||||
"LR")
|
||||
"LR")
|
||||
params[:pdf].SetY(params[:top])
|
||||
params[:pdf].SetX(params[:subject_width])
|
||||
params[:pdf].RDMCell(params[:g_width], 5, "", "LR")
|
||||
|
@ -734,8 +804,10 @@ module Redmine
|
|||
def image_subject(params, subject, options={})
|
||||
params[:image].fill('black')
|
||||
params[:image].stroke('transparent')
|
||||
params[:image].stroke_width(1)
|
||||
params[:image].text(params[:indent], params[:top] + 2, subject)
|
||||
params[:image].strokewidth(1)
|
||||
params[:image].draw('text %d,%d %s' % [
|
||||
params[:indent], params[:top] + 2, Redmine::Utils::Shell.shell_quote(subject)
|
||||
])
|
||||
end
|
||||
|
||||
def issue_relations(issue)
|
||||
|
@ -749,9 +821,11 @@ module Redmine
|
|||
end
|
||||
|
||||
def html_task(params, coords, markers, label, object)
|
||||
output = ''
|
||||
|
||||
css = "task " + case object
|
||||
output = +''
|
||||
data_options = {}
|
||||
data_options[:collapse_expand] = "#{object.class}-#{object.id}".downcase if object
|
||||
css = "task " +
|
||||
case object
|
||||
when Project
|
||||
"project"
|
||||
when Version
|
||||
|
@ -761,11 +835,10 @@ module Redmine
|
|||
else
|
||||
""
|
||||
end
|
||||
|
||||
# Renders the task bar, with progress and late
|
||||
if coords[:bar_start] && coords[:bar_end]
|
||||
width = coords[:bar_end] - coords[:bar_start] - 2
|
||||
style = ""
|
||||
style = +""
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:bar_start]}px;"
|
||||
style << "width:#{width}px;"
|
||||
|
@ -773,27 +846,30 @@ module Redmine
|
|||
html_id = "task-todo-version-#{object.id}" if object.is_a?(Version)
|
||||
content_opt = {:style => style,
|
||||
:class => "#{css} task_todo",
|
||||
:id => html_id}
|
||||
:id => html_id,
|
||||
:data => {}}
|
||||
if object.is_a?(Issue)
|
||||
rels = issue_relations(object)
|
||||
if rels.present?
|
||||
content_opt[:data] = {"rels" => rels.to_json}
|
||||
end
|
||||
end
|
||||
content_opt[:data].merge!(data_options)
|
||||
output << view.content_tag(:div, ' '.html_safe, content_opt)
|
||||
if coords[:bar_late_end]
|
||||
width = coords[:bar_late_end] - coords[:bar_start] - 2
|
||||
style = ""
|
||||
style = +""
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:bar_start]}px;"
|
||||
style << "width:#{width}px;"
|
||||
output << view.content_tag(:div, ' '.html_safe,
|
||||
:style => style,
|
||||
:class => "#{css} task_late")
|
||||
:class => "#{css} task_late",
|
||||
:data => data_options)
|
||||
end
|
||||
if coords[:bar_progress_end]
|
||||
width = coords[:bar_progress_end] - coords[:bar_start] - 2
|
||||
style = ""
|
||||
style = +""
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:bar_start]}px;"
|
||||
style << "width:#{width}px;"
|
||||
|
@ -802,46 +878,51 @@ module Redmine
|
|||
output << view.content_tag(:div, ' '.html_safe,
|
||||
:style => style,
|
||||
:class => "#{css} task_done",
|
||||
:id => html_id)
|
||||
:id => html_id,
|
||||
:data => data_options)
|
||||
end
|
||||
end
|
||||
# Renders the markers
|
||||
if markers
|
||||
if coords[:start]
|
||||
style = ""
|
||||
style = +""
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:start]}px;"
|
||||
style << "width:15px;"
|
||||
output << view.content_tag(:div, ' '.html_safe,
|
||||
:style => style,
|
||||
:class => "#{css} marker starting")
|
||||
:class => "#{css} marker starting",
|
||||
:data => data_options)
|
||||
end
|
||||
if coords[:end]
|
||||
style = ""
|
||||
style = +""
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:end] + params[:zoom]}px;"
|
||||
style << "left:#{coords[:end]}px;"
|
||||
style << "width:15px;"
|
||||
output << view.content_tag(:div, ' '.html_safe,
|
||||
:style => style,
|
||||
:class => "#{css} marker ending")
|
||||
:class => "#{css} marker ending",
|
||||
:data => data_options)
|
||||
end
|
||||
end
|
||||
# Renders the label on the right
|
||||
if label
|
||||
style = ""
|
||||
style = +""
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{(coords[:bar_end] || 0) + 8}px;"
|
||||
style << "width:15px;"
|
||||
output << view.content_tag(:div, label,
|
||||
:style => style,
|
||||
:class => "#{css} label")
|
||||
:class => "#{css} label",
|
||||
:data => data_options)
|
||||
end
|
||||
# Renders the tooltip
|
||||
if object.is_a?(Issue) && coords[:bar_start] && coords[:bar_end]
|
||||
s = view.content_tag(:span,
|
||||
view.render_issue_tooltip(object).html_safe,
|
||||
:class => "tip")
|
||||
style = ""
|
||||
s += view.content_tag(:input, nil, :type => 'checkbox', :name => 'ids[]', :value => object.id, :style => 'display:none;', :class => 'toggle-selection')
|
||||
style = +""
|
||||
style << "position: absolute;"
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:bar_start]}px;"
|
||||
|
@ -849,7 +930,8 @@ module Redmine
|
|||
style << "height:12px;"
|
||||
output << view.content_tag(:div, s.html_safe,
|
||||
:style => style,
|
||||
:class => "tooltip")
|
||||
:class => "tooltip hascontextmenu",
|
||||
:data => data_options)
|
||||
end
|
||||
@lines << output
|
||||
output
|
||||
|
@ -863,21 +945,24 @@ module Redmine
|
|||
height /= 2 if markers
|
||||
# Renders the task bar, with progress and late
|
||||
if coords[:bar_start] && coords[:bar_end]
|
||||
width = [1, coords[:bar_end] - coords[:bar_start]].max
|
||||
params[:pdf].SetY(params[:top] + 1.5)
|
||||
params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
|
||||
params[:pdf].SetFillColor(200, 200, 200)
|
||||
params[:pdf].RDMCell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1)
|
||||
params[:pdf].RDMCell(width, height, "", 0, 0, "", 1)
|
||||
if coords[:bar_late_end]
|
||||
width = [1, coords[:bar_late_end] - coords[:bar_start]].max
|
||||
params[:pdf].SetY(params[:top] + 1.5)
|
||||
params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
|
||||
params[:pdf].SetFillColor(255, 100, 100)
|
||||
params[:pdf].RDMCell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1)
|
||||
params[:pdf].RDMCell(width, height, "", 0, 0, "", 1)
|
||||
end
|
||||
if coords[:bar_progress_end]
|
||||
width = [1, coords[:bar_progress_end] - coords[:bar_start]].max
|
||||
params[:pdf].SetY(params[:top] + 1.5)
|
||||
params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
|
||||
params[:pdf].SetFillColor(90, 200, 90)
|
||||
params[:pdf].RDMCell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1)
|
||||
params[:pdf].RDMCell(width, height, "", 0, 0, "", 1)
|
||||
end
|
||||
end
|
||||
# Renders the markers
|
||||
|
@ -910,23 +995,29 @@ module Redmine
|
|||
# Renders the task bar, with progress and late
|
||||
if coords[:bar_start] && coords[:bar_end]
|
||||
params[:image].fill('#aaa')
|
||||
params[:image].rectangle(params[:subject_width] + coords[:bar_start],
|
||||
params[:top],
|
||||
params[:subject_width] + coords[:bar_end],
|
||||
params[:top] - height)
|
||||
params[:image].draw('rectangle %d,%d %d,%d' % [
|
||||
params[:subject_width] + coords[:bar_start],
|
||||
params[:top],
|
||||
params[:subject_width] + coords[:bar_end],
|
||||
params[:top] - height
|
||||
])
|
||||
if coords[:bar_late_end]
|
||||
params[:image].fill('#f66')
|
||||
params[:image].rectangle(params[:subject_width] + coords[:bar_start],
|
||||
params[:top],
|
||||
params[:subject_width] + coords[:bar_late_end],
|
||||
params[:top] - height)
|
||||
params[:image].draw('rectangle %d,%d %d,%d' % [
|
||||
params[:subject_width] + coords[:bar_start],
|
||||
params[:top],
|
||||
params[:subject_width] + coords[:bar_late_end],
|
||||
params[:top] - height
|
||||
])
|
||||
end
|
||||
if coords[:bar_progress_end]
|
||||
params[:image].fill('#00c600')
|
||||
params[:image].rectangle(params[:subject_width] + coords[:bar_start],
|
||||
params[:top],
|
||||
params[:subject_width] + coords[:bar_progress_end],
|
||||
params[:top] - height)
|
||||
params[:image].draw('rectangle %d,%d %d,%d' % [
|
||||
params[:subject_width] + coords[:bar_start],
|
||||
params[:top],
|
||||
params[:subject_width] + coords[:bar_progress_end],
|
||||
params[:top] - height
|
||||
])
|
||||
end
|
||||
end
|
||||
# Renders the markers
|
||||
|
@ -935,21 +1026,31 @@ module Redmine
|
|||
x = params[:subject_width] + coords[:start]
|
||||
y = params[:top] - height / 2
|
||||
params[:image].fill('blue')
|
||||
params[:image].polygon(x - 4, y, x, y - 4, x + 4, y, x, y + 4)
|
||||
params[:image].draw('polygon %d,%d %d,%d %d,%d %d,%d' % [
|
||||
x - 4, y,
|
||||
x, y - 4,
|
||||
x + 4, y,
|
||||
x, y + 4
|
||||
])
|
||||
end
|
||||
if coords[:end]
|
||||
x = params[:subject_width] + coords[:end] + params[:zoom]
|
||||
x = params[:subject_width] + coords[:end]
|
||||
y = params[:top] - height / 2
|
||||
params[:image].fill('blue')
|
||||
params[:image].polygon(x - 4, y, x, y - 4, x + 4, y, x, y + 4)
|
||||
params[:image].draw('polygon %d,%d %d,%d %d,%d %d,%d' % [
|
||||
x - 4, y,
|
||||
x, y - 4,
|
||||
x + 4, y,
|
||||
x, y + 4
|
||||
])
|
||||
end
|
||||
end
|
||||
# Renders the label on the right
|
||||
if label
|
||||
params[:image].fill('black')
|
||||
params[:image].text(params[:subject_width] + (coords[:bar_end] || 0) + 5,
|
||||
params[:top] + 1,
|
||||
label)
|
||||
params[:image].draw('text %d,%d %s' % [
|
||||
params[:subject_width] + (coords[:bar_end] || 0) + 5, params[:top] + 1, Redmine::Utils::Shell.shell_quote(label)
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue