%>
+
+<% if @gantt.truncated %>
+ <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
+<% end %>
+
<table width="100%" style="border:0; border-collapse: collapse;">
<tr>
<td style="width:<%= subject_width %>px; padding:0px;">
<p><%= setting_select :issue_done_ratio, Issue::DONE_RATIO_OPTIONS.collect {|i| [l("setting_issue_done_ratio_#{i}"), i]} %></p>
<p><%= setting_text_field :issues_export_limit, :size => 6 %></p>
+
+<p><%= setting_text_field :gantt_items_limit, :size => 6 %></p>
</div>
<fieldset class="box settings"><legend><%= l(:setting_issue_list_default_columns) %></legend>
notice_unable_delete_version: Unable to delete version.
notice_unable_delete_time_entry: Unable to delete time log entry.
notice_issue_done_ratios_updated: Issue done ratios updated.
+ notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed ({{max}})"
error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}"
error_scm_not_found: "The entry or revision was not found in the repository."
setting_default_notification_option: Default notification option
setting_commit_logtime_enabled: Enable time logging
setting_commit_logtime_activity_id: Activity for logged time
+ setting_gantt_items_limit: Maximum number of items displayed on the gantt chart
permission_add_project: Create project
permission_add_subprojects: Create subprojects
notice_unable_delete_version: Impossible de supprimer cette version.
notice_issue_done_ratios_updated: L'avancement des demandes a été mis à jour.
notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée.
+ notice_gantt_chart_truncated: "Le diagramme a été tronqué car il excède le nombre maximal d'éléments pouvant être affichés ({{max}})"
error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage : {{value}}"
error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
setting_cache_formatted_text: Mettre en cache le texte formaté
setting_commit_logtime_enabled: Permettre la saisie de temps
setting_commit_logtime_activity_id: Activité pour le temps saisi
+ setting_gantt_items_limit: Nombre maximum d'éléments affichés sur le gantt
permission_add_project: Créer un projet
permission_add_subprojects: Créer des sous-projets
feeds_limit:
format: int
default: 15
+gantt_items_limit:
+ format: int
+ default: 500
# Maximum size of files that can be displayed
# inline through the file viewer (in KB)
file_max_size_displayed:
end
end
- attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months
+ attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months, :truncated, :max_rows
attr_accessor :query
attr_accessor :project
attr_accessor :view
@subjects = ''
@lines = ''
@number_of_rows = nil
+
+ @truncated = false
+ if options.has_key?(:max_rows)
+ @max_rows = options[:max_rows]
+ else
+ @max_rows = Setting.gantt_items_limit.blank? ? nil : Setting.gantt_items_limit.to_i
+ end
end
def common_params
def number_of_rows
return @number_of_rows if @number_of_rows
- if @project
- return number_of_rows_on_project(@project)
+ rows = if @project
+ number_of_rows_on_project(@project)
else
Project.roots.visible.has_module('issue_tracking').inject(0) do |total, project|
total += number_of_rows_on_project(project)
end
end
+
+ rows > @max_rows ? @max_rows : rows
end
# Returns the number of rows that will be used to list a project on
else
Project.roots.visible.has_module('issue_tracking').each do |project|
render_project(project, options)
+ break if abort?
end
end
options[:top] += options[:top_increment]
options[:indent] += options[:indent_increment]
@number_of_rows += 1
+ return if abort?
# Second, Issues without a version
- issues = project.issues.for_gantt.without_version.with_query(@query)
+ issues = project.issues.for_gantt.without_version.with_query(@query).all(:limit => current_limit)
sort_issues!(issues)
if issues
render_issues(issues, options)
+ return if abort?
end
# Third, Versions
project.versions.sort.each do |version|
render_version(version, options)
+ return if abort?
end
# Fourth, subprojects
project.children.visible.has_module('issue_tracking').each do |project|
render_project(project, options)
+ return if abort?
end
# Remove indent to hit the next sibling
options[:top] += options[:top_increment]
@number_of_rows += 1
+ return if abort?
end
end
options[:top] += options[:top_increment]
@number_of_rows += 1
+ return if abort?
# Remove the project requirement for Versions because it will
# restrict issues to only be on the current project. This
# ends up missing issues which are assigned to shared versions.
@query.project = nil if @query.project
- issues = version.fixed_issues.for_gantt.with_query(@query)
+ issues = version.fixed_issues.for_gantt.with_query(@query).all(:limit => current_limit)
if issues
sort_issues!(issues)
# Indent issues
end
end
+ def current_limit
+ if @max_rows
+ @max_rows - @number_of_rows
+ else
+ nil
+ end
+ end
+
+ def abort?
+ if @max_rows && @number_of_rows >= @max_rows
+ @truncated = true
+ end
+ end
+
def pdf_new_page?(options)
if options[:top] > 180
options[:pdf].Line(15, options[:top], PDF::TotalWidth, options[:top])
end
# Creates a Gantt chart for a 4 week span
- def create_gantt(project=Project.generate!)
+ def create_gantt(project=Project.generate!, options={})
@project = project
- @gantt = Redmine::Helpers::Gantt.new
+ @gantt = Redmine::Helpers::Gantt.new(options)
@gantt.project = @project
@gantt.query = Query.generate_default!(:project => @project)
@gantt.view = build_view
should "return the total number of rows for all the projects, resursively"
end
+ should "not exceed max_rows option" do
+ p = Project.generate!
+ 5.times do
+ Issue.generate_for_project!(p)
+ end
+
+ create_gantt(p)
+ @gantt.render
+ assert_equal 6, @gantt.number_of_rows
+ assert !@gantt.truncated
+
+ create_gantt(p, :max_rows => 3)
+ @gantt.render
+ assert_equal 3, @gantt.number_of_rows
+ assert @gantt.truncated
+ end
end
context "#number_of_rows_on_project" do