##// END OF EJS Templates
Adds an application setting to limit the number of items that can be displayed on the gantt chart (#6276)....
Jean-Philippe Lang -
r4399:b48291ec63b5
parent child
Show More
@@ -67,6 +67,11 t_height = g_height + headers_height
67 67
68 68
69 69 %>
70
71 <% if @gantt.truncated %>
72 <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
73 <% end %>
74
70 75 <table width="100%" style="border:0; border-collapse: collapse;">
71 76 <tr>
72 77 <td style="width:<%= subject_width %>px; padding:0px;">
@@ -8,6 +8,8
8 8 <p><%= setting_select :issue_done_ratio, Issue::DONE_RATIO_OPTIONS.collect {|i| [l("setting_issue_done_ratio_#{i}"), i]} %></p>
9 9
10 10 <p><%= setting_text_field :issues_export_limit, :size => 6 %></p>
11
12 <p><%= setting_text_field :gantt_items_limit, :size => 6 %></p>
11 13 </div>
12 14
13 15 <fieldset class="box settings"><legend><%= l(:setting_issue_list_default_columns) %></legend>
@@ -163,6 +163,7 en:
163 163 notice_unable_delete_version: Unable to delete version.
164 164 notice_unable_delete_time_entry: Unable to delete time log entry.
165 165 notice_issue_done_ratios_updated: Issue done ratios updated.
166 notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed ({{max}})"
166 167
167 168 error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}"
168 169 error_scm_not_found: "The entry or revision was not found in the repository."
@@ -356,6 +357,7 en:
356 357 setting_default_notification_option: Default notification option
357 358 setting_commit_logtime_enabled: Enable time logging
358 359 setting_commit_logtime_activity_id: Activity for logged time
360 setting_gantt_items_limit: Maximum number of items displayed on the gantt chart
359 361
360 362 permission_add_project: Create project
361 363 permission_add_subprojects: Create subprojects
@@ -180,6 +180,7 fr:
180 180 notice_unable_delete_version: Impossible de supprimer cette version.
181 181 notice_issue_done_ratios_updated: L'avancement des demandes a été mis à jour.
182 182 notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée.
183 notice_gantt_chart_truncated: "Le diagramme a été tronqué car il excède le nombre maximal d'éléments pouvant être affichés ({{max}})"
183 184
184 185 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage : {{value}}"
185 186 error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
@@ -360,6 +361,7 fr:
360 361 setting_cache_formatted_text: Mettre en cache le texte formaté
361 362 setting_commit_logtime_enabled: Permettre la saisie de temps
362 363 setting_commit_logtime_activity_id: Activité pour le temps saisi
364 setting_gantt_items_limit: Nombre maximum d'éléments affichés sur le gantt
363 365
364 366 permission_add_project: Créer un projet
365 367 permission_add_subprojects: Créer des sous-projets
@@ -66,6 +66,9 protocol:
66 66 feeds_limit:
67 67 format: int
68 68 default: 15
69 gantt_items_limit:
70 format: int
71 default: 500
69 72 # Maximum size of files that can be displayed
70 73 # inline through the file viewer (in KB)
71 74 file_max_size_displayed:
@@ -34,7 +34,7 module Redmine
34 34 end
35 35 end
36 36
37 attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months
37 attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months, :truncated, :max_rows
38 38 attr_accessor :query
39 39 attr_accessor :project
40 40 attr_accessor :view
@@ -71,6 +71,13 module Redmine
71 71 @subjects = ''
72 72 @lines = ''
73 73 @number_of_rows = nil
74
75 @truncated = false
76 if options.has_key?(:max_rows)
77 @max_rows = options[:max_rows]
78 else
79 @max_rows = Setting.gantt_items_limit.blank? ? nil : Setting.gantt_items_limit.to_i
80 end
74 81 end
75 82
76 83 def common_params
@@ -94,13 +101,15 module Redmine
94 101 def number_of_rows
95 102 return @number_of_rows if @number_of_rows
96 103
97 if @project
98 return number_of_rows_on_project(@project)
104 rows = if @project
105 number_of_rows_on_project(@project)
99 106 else
100 107 Project.roots.visible.has_module('issue_tracking').inject(0) do |total, project|
101 108 total += number_of_rows_on_project(project)
102 109 end
103 110 end
111
112 rows > @max_rows ? @max_rows : rows
104 113 end
105 114
106 115 # Returns the number of rows that will be used to list a project on
@@ -156,6 +165,7 module Redmine
156 165 else
157 166 Project.roots.visible.has_module('issue_tracking').each do |project|
158 167 render_project(project, options)
168 break if abort?
159 169 end
160 170 end
161 171
@@ -176,22 +186,26 module Redmine
176 186 options[:top] += options[:top_increment]
177 187 options[:indent] += options[:indent_increment]
178 188 @number_of_rows += 1
189 return if abort?
179 190
180 191 # Second, Issues without a version
181 issues = project.issues.for_gantt.without_version.with_query(@query)
192 issues = project.issues.for_gantt.without_version.with_query(@query).all(:limit => current_limit)
182 193 sort_issues!(issues)
183 194 if issues
184 195 render_issues(issues, options)
196 return if abort?
185 197 end
186 198
187 199 # Third, Versions
188 200 project.versions.sort.each do |version|
189 201 render_version(version, options)
202 return if abort?
190 203 end
191 204
192 205 # Fourth, subprojects
193 206 project.children.visible.has_module('issue_tracking').each do |project|
194 207 render_project(project, options)
208 return if abort?
195 209 end
196 210
197 211 # Remove indent to hit the next sibling
@@ -205,6 +219,7 module Redmine
205 219
206 220 options[:top] += options[:top_increment]
207 221 @number_of_rows += 1
222 return if abort?
208 223 end
209 224 end
210 225
@@ -215,13 +230,14 module Redmine
215 230
216 231 options[:top] += options[:top_increment]
217 232 @number_of_rows += 1
233 return if abort?
218 234
219 235 # Remove the project requirement for Versions because it will
220 236 # restrict issues to only be on the current project. This
221 237 # ends up missing issues which are assigned to shared versions.
222 238 @query.project = nil if @query.project
223 239
224 issues = version.fixed_issues.for_gantt.with_query(@query)
240 issues = version.fixed_issues.for_gantt.with_query(@query).all(:limit => current_limit)
225 241 if issues
226 242 sort_issues!(issues)
227 243 # Indent issues
@@ -961,6 +977,20 module Redmine
961 977 end
962 978 end
963 979
980 def current_limit
981 if @max_rows
982 @max_rows - @number_of_rows
983 else
984 nil
985 end
986 end
987
988 def abort?
989 if @max_rows && @number_of_rows >= @max_rows
990 @truncated = true
991 end
992 end
993
964 994 def pdf_new_page?(options)
965 995 if options[:top] > 180
966 996 options[:pdf].Line(15, options[:top], PDF::TotalWidth, options[:top])
@@ -53,9 +53,9 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
53 53 end
54 54
55 55 # Creates a Gantt chart for a 4 week span
56 def create_gantt(project=Project.generate!)
56 def create_gantt(project=Project.generate!, options={})
57 57 @project = project
58 @gantt = Redmine::Helpers::Gantt.new
58 @gantt = Redmine::Helpers::Gantt.new(options)
59 59 @gantt.project = @project
60 60 @gantt.query = Query.generate_default!(:project => @project)
61 61 @gantt.view = build_view
@@ -73,6 +73,22 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
73 73 should "return the total number of rows for all the projects, resursively"
74 74 end
75 75
76 should "not exceed max_rows option" do
77 p = Project.generate!
78 5.times do
79 Issue.generate_for_project!(p)
80 end
81
82 create_gantt(p)
83 @gantt.render
84 assert_equal 6, @gantt.number_of_rows
85 assert !@gantt.truncated
86
87 create_gantt(p, :max_rows => 3)
88 @gantt.render
89 assert_equal 3, @gantt.number_of_rows
90 assert @gantt.truncated
91 end
76 92 end
77 93
78 94 context "#number_of_rows_on_project" do
General Comments 0
You need to be logged in to leave comments. Login now