##// END OF EJS Templates
Refactoring ApplicationHelper#link_to_issue....
Jean-Philippe Lang -
r2926:cbeeaa4d4d47
parent child
Show More
@@ -1,680 +1,700
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'coderay'
19 19 require 'coderay/helpers/file_type'
20 20 require 'forwardable'
21 21 require 'cgi'
22 22
23 23 module ApplicationHelper
24 24 include Redmine::WikiFormatting::Macros::Definitions
25 25 include Redmine::I18n
26 26 include GravatarHelper::PublicMethods
27 27
28 28 extend Forwardable
29 29 def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
30 30
31 31 # Return true if user is authorized for controller/action, otherwise false
32 32 def authorize_for(controller, action)
33 33 User.current.allowed_to?({:controller => controller, :action => action}, @project)
34 34 end
35 35
36 36 # Display a link if user is authorized
37 37 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
38 38 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
39 39 end
40 40
41 41 # Display a link to remote if user is authorized
42 42 def link_to_remote_if_authorized(name, options = {}, html_options = nil)
43 43 url = options[:url] || {}
44 44 link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
45 45 end
46 46
47 47 # Displays a link to user's account page if active
48 48 def link_to_user(user, options={})
49 49 if user.is_a?(User)
50 50 name = h(user.name(options[:format]))
51 51 if user.active?
52 52 link_to name, :controller => 'users', :action => 'show', :id => user
53 53 else
54 54 name
55 55 end
56 56 else
57 57 h(user.to_s)
58 58 end
59 59 end
60 60
61 # Displays a link to +issue+ with its subject.
62 # Examples:
63 #
64 # link_to_issue(issue) # => Defect #6: This is the subject
65 # link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
66 # link_to_issue(issue, :subject => false) # => Defect #6
67 #
61 68 def link_to_issue(issue, options={})
62 options[:class] ||= issue.css_classes
63 link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options
69 title = nil
70 subject = nil
71 if options[:subject] == false
72 title = truncate(issue.subject, :length => 60)
73 else
74 subject = issue.subject
75 if options[:truncate]
76 subject = truncate(subject, :length => options[:truncate])
77 end
78 end
79 s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
80 :class => issue.css_classes,
81 :title => title
82 s << ": #{h subject}" if subject
83 s
64 84 end
65 85
66 86 # Generates a link to an attachment.
67 87 # Options:
68 88 # * :text - Link text (default to attachment filename)
69 89 # * :download - Force download (default: false)
70 90 def link_to_attachment(attachment, options={})
71 91 text = options.delete(:text) || attachment.filename
72 92 action = options.delete(:download) ? 'download' : 'show'
73 93
74 94 link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
75 95 end
76 96
77 97 def toggle_link(name, id, options={})
78 98 onclick = "Element.toggle('#{id}'); "
79 99 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
80 100 onclick << "return false;"
81 101 link_to(name, "#", :onclick => onclick)
82 102 end
83 103
84 104 def image_to_function(name, function, html_options = {})
85 105 html_options.symbolize_keys!
86 106 tag(:input, html_options.merge({
87 107 :type => "image", :src => image_path(name),
88 108 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
89 109 }))
90 110 end
91 111
92 112 def prompt_to_remote(name, text, param, url, html_options = {})
93 113 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
94 114 link_to name, {}, html_options
95 115 end
96 116
97 117 def format_activity_title(text)
98 118 h(truncate_single_line(text, :length => 100))
99 119 end
100 120
101 121 def format_activity_day(date)
102 122 date == Date.today ? l(:label_today).titleize : format_date(date)
103 123 end
104 124
105 125 def format_activity_description(text)
106 126 h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
107 127 end
108 128
109 129 def due_date_distance_in_words(date)
110 130 if date
111 131 l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
112 132 end
113 133 end
114 134
115 135 def render_page_hierarchy(pages, node=nil)
116 136 content = ''
117 137 if pages[node]
118 138 content << "<ul class=\"pages-hierarchy\">\n"
119 139 pages[node].each do |page|
120 140 content << "<li>"
121 141 content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :id => page.project, :page => page.title},
122 142 :title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
123 143 content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id]
124 144 content << "</li>\n"
125 145 end
126 146 content << "</ul>\n"
127 147 end
128 148 content
129 149 end
130 150
131 151 # Renders flash messages
132 152 def render_flash_messages
133 153 s = ''
134 154 flash.each do |k,v|
135 155 s << content_tag('div', v, :class => "flash #{k}")
136 156 end
137 157 s
138 158 end
139 159
140 160 # Renders tabs and their content
141 161 def render_tabs(tabs)
142 162 if tabs.any?
143 163 render :partial => 'common/tabs', :locals => {:tabs => tabs}
144 164 else
145 165 content_tag 'p', l(:label_no_data), :class => "nodata"
146 166 end
147 167 end
148 168
149 169 # Renders the project quick-jump box
150 170 def render_project_jump_box
151 171 # Retrieve them now to avoid a COUNT query
152 172 projects = User.current.projects.all
153 173 if projects.any?
154 174 s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
155 175 "<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
156 176 '<option value="" disabled="disabled">---</option>'
157 177 s << project_tree_options_for_select(projects, :selected => @project) do |p|
158 178 { :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
159 179 end
160 180 s << '</select>'
161 181 s
162 182 end
163 183 end
164 184
165 185 def project_tree_options_for_select(projects, options = {})
166 186 s = ''
167 187 project_tree(projects) do |project, level|
168 188 name_prefix = (level > 0 ? ('&nbsp;' * 2 * level + '&#187; ') : '')
169 189 tag_options = {:value => project.id, :selected => ((project == options[:selected]) ? 'selected' : nil)}
170 190 tag_options.merge!(yield(project)) if block_given?
171 191 s << content_tag('option', name_prefix + h(project), tag_options)
172 192 end
173 193 s
174 194 end
175 195
176 196 # Yields the given block for each project with its level in the tree
177 197 def project_tree(projects, &block)
178 198 ancestors = []
179 199 projects.sort_by(&:lft).each do |project|
180 200 while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
181 201 ancestors.pop
182 202 end
183 203 yield project, ancestors.size
184 204 ancestors << project
185 205 end
186 206 end
187 207
188 208 def project_nested_ul(projects, &block)
189 209 s = ''
190 210 if projects.any?
191 211 ancestors = []
192 212 projects.sort_by(&:lft).each do |project|
193 213 if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
194 214 s << "<ul>\n"
195 215 else
196 216 ancestors.pop
197 217 s << "</li>"
198 218 while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
199 219 ancestors.pop
200 220 s << "</ul></li>\n"
201 221 end
202 222 end
203 223 s << "<li>"
204 224 s << yield(project).to_s
205 225 ancestors << project
206 226 end
207 227 s << ("</li></ul>\n" * ancestors.size)
208 228 end
209 229 s
210 230 end
211 231
212 232 def principals_check_box_tags(name, principals)
213 233 s = ''
214 234 principals.sort.each do |principal|
215 235 s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
216 236 end
217 237 s
218 238 end
219 239
220 240 # Truncates and returns the string as a single line
221 241 def truncate_single_line(string, *args)
222 242 truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
223 243 end
224 244
225 245 def html_hours(text)
226 246 text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
227 247 end
228 248
229 249 def authoring(created, author, options={})
230 250 l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created))
231 251 end
232 252
233 253 def time_tag(time)
234 254 text = distance_of_time_in_words(Time.now, time)
235 255 if @project
236 256 link_to(text, {:controller => 'projects', :action => 'activity', :id => @project, :from => time.to_date}, :title => format_time(time))
237 257 else
238 258 content_tag('acronym', text, :title => format_time(time))
239 259 end
240 260 end
241 261
242 262 def syntax_highlight(name, content)
243 263 type = CodeRay::FileType[name]
244 264 type ? CodeRay.scan(content, type).html : h(content)
245 265 end
246 266
247 267 def to_path_param(path)
248 268 path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
249 269 end
250 270
251 271 def pagination_links_full(paginator, count=nil, options={})
252 272 page_param = options.delete(:page_param) || :page
253 273 url_param = params.dup
254 274 # don't reuse query params if filters are present
255 275 url_param.merge!(:fields => nil, :values => nil, :operators => nil) if url_param.delete(:set_filter)
256 276
257 277 html = ''
258 278 if paginator.current.previous
259 279 html << link_to_remote_content_update('&#171; ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
260 280 end
261 281
262 282 html << (pagination_links_each(paginator, options) do |n|
263 283 link_to_remote_content_update(n.to_s, url_param.merge(page_param => n))
264 284 end || '')
265 285
266 286 if paginator.current.next
267 287 html << ' ' + link_to_remote_content_update((l(:label_next) + ' &#187;'), url_param.merge(page_param => paginator.current.next))
268 288 end
269 289
270 290 unless count.nil?
271 291 html << [
272 292 " (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})",
273 293 per_page_links(paginator.items_per_page)
274 294 ].compact.join(' | ')
275 295 end
276 296
277 297 html
278 298 end
279 299
280 300 def per_page_links(selected=nil)
281 301 url_param = params.dup
282 302 url_param.clear if url_param.has_key?(:set_filter)
283 303
284 304 links = Setting.per_page_options_array.collect do |n|
285 305 n == selected ? n : link_to_remote(n, {:update => "content",
286 306 :url => params.dup.merge(:per_page => n),
287 307 :method => :get},
288 308 {:href => url_for(url_param.merge(:per_page => n))})
289 309 end
290 310 links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
291 311 end
292 312
293 313 def reorder_links(name, url)
294 314 link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), url.merge({"#{name}[move_to]" => 'highest'}), :method => :post, :title => l(:label_sort_highest)) +
295 315 link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), url.merge({"#{name}[move_to]" => 'higher'}), :method => :post, :title => l(:label_sort_higher)) +
296 316 link_to(image_tag('1downarrow.png', :alt => l(:label_sort_lower)), url.merge({"#{name}[move_to]" => 'lower'}), :method => :post, :title => l(:label_sort_lower)) +
297 317 link_to(image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), url.merge({"#{name}[move_to]" => 'lowest'}), :method => :post, :title => l(:label_sort_lowest))
298 318 end
299 319
300 320 def breadcrumb(*args)
301 321 elements = args.flatten
302 322 elements.any? ? content_tag('p', args.join(' &#187; ') + ' &#187; ', :class => 'breadcrumb') : nil
303 323 end
304 324
305 325 def other_formats_links(&block)
306 326 concat('<p class="other-formats">' + l(:label_export_to))
307 327 yield Redmine::Views::OtherFormatsBuilder.new(self)
308 328 concat('</p>')
309 329 end
310 330
311 331 def page_header_title
312 332 if @project.nil? || @project.new_record?
313 333 h(Setting.app_title)
314 334 else
315 335 b = []
316 336 ancestors = (@project.root? ? [] : @project.ancestors.visible)
317 337 if ancestors.any?
318 338 root = ancestors.shift
319 339 b << link_to(h(root), {:controller => 'projects', :action => 'show', :id => root, :jump => current_menu_item}, :class => 'root')
320 340 if ancestors.size > 2
321 341 b << '&#8230;'
322 342 ancestors = ancestors[-2, 2]
323 343 end
324 344 b += ancestors.collect {|p| link_to(h(p), {:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item}, :class => 'ancestor') }
325 345 end
326 346 b << h(@project)
327 347 b.join(' &#187; ')
328 348 end
329 349 end
330 350
331 351 def html_title(*args)
332 352 if args.empty?
333 353 title = []
334 354 title << @project.name if @project
335 355 title += @html_title if @html_title
336 356 title << Setting.app_title
337 357 title.select {|t| !t.blank? }.join(' - ')
338 358 else
339 359 @html_title ||= []
340 360 @html_title += args
341 361 end
342 362 end
343 363
344 364 def accesskey(s)
345 365 Redmine::AccessKeys.key_for s
346 366 end
347 367
348 368 # Formats text according to system settings.
349 369 # 2 ways to call this method:
350 370 # * with a String: textilizable(text, options)
351 371 # * with an object and one of its attribute: textilizable(issue, :description, options)
352 372 def textilizable(*args)
353 373 options = args.last.is_a?(Hash) ? args.pop : {}
354 374 case args.size
355 375 when 1
356 376 obj = options[:object]
357 377 text = args.shift
358 378 when 2
359 379 obj = args.shift
360 380 text = obj.send(args.shift).to_s
361 381 else
362 382 raise ArgumentError, 'invalid arguments to textilizable'
363 383 end
364 384 return '' if text.blank?
365 385
366 386 only_path = options.delete(:only_path) == false ? false : true
367 387
368 388 # when using an image link, try to use an attachment, if possible
369 389 attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
370 390
371 391 if attachments
372 392 attachments = attachments.sort_by(&:created_on).reverse
373 393 text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
374 394 style = $1
375 395 filename = $6.downcase
376 396 # search for the picture in attachments
377 397 if found = attachments.detect { |att| att.filename.downcase == filename }
378 398 image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
379 399 desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
380 400 alt = desc.blank? ? nil : "(#{desc})"
381 401 "!#{style}#{image_url}#{alt}!"
382 402 else
383 403 m
384 404 end
385 405 end
386 406 end
387 407
388 408 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
389 409
390 410 # different methods for formatting wiki links
391 411 case options[:wiki_links]
392 412 when :local
393 413 # used for local links to html files
394 414 format_wiki_link = Proc.new {|project, title, anchor| "#{title}.html" }
395 415 when :anchor
396 416 # used for single-file wiki export
397 417 format_wiki_link = Proc.new {|project, title, anchor| "##{title}" }
398 418 else
399 419 format_wiki_link = Proc.new {|project, title, anchor| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title, :anchor => anchor) }
400 420 end
401 421
402 422 project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
403 423
404 424 # Wiki links
405 425 #
406 426 # Examples:
407 427 # [[mypage]]
408 428 # [[mypage|mytext]]
409 429 # wiki links can refer other project wikis, using project name or identifier:
410 430 # [[project:]] -> wiki starting page
411 431 # [[project:|mytext]]
412 432 # [[project:mypage]]
413 433 # [[project:mypage|mytext]]
414 434 text = text.gsub(/(!)?(\[\[([^\]\n\|]+)(\|([^\]\n\|]+))?\]\])/) do |m|
415 435 link_project = project
416 436 esc, all, page, title = $1, $2, $3, $5
417 437 if esc.nil?
418 438 if page =~ /^([^\:]+)\:(.*)$/
419 439 link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
420 440 page = $2
421 441 title ||= $1 if page.blank?
422 442 end
423 443
424 444 if link_project && link_project.wiki
425 445 # extract anchor
426 446 anchor = nil
427 447 if page =~ /^(.+?)\#(.+)$/
428 448 page, anchor = $1, $2
429 449 end
430 450 # check if page exists
431 451 wiki_page = link_project.wiki.find_page(page)
432 452 link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page), anchor),
433 453 :class => ('wiki-page' + (wiki_page ? '' : ' new')))
434 454 else
435 455 # project or wiki doesn't exist
436 456 all
437 457 end
438 458 else
439 459 all
440 460 end
441 461 end
442 462
443 463 # Redmine links
444 464 #
445 465 # Examples:
446 466 # Issues:
447 467 # #52 -> Link to issue #52
448 468 # Changesets:
449 469 # r52 -> Link to revision 52
450 470 # commit:a85130f -> Link to scmid starting with a85130f
451 471 # Documents:
452 472 # document#17 -> Link to document with id 17
453 473 # document:Greetings -> Link to the document with title "Greetings"
454 474 # document:"Some document" -> Link to the document with title "Some document"
455 475 # Versions:
456 476 # version#3 -> Link to version with id 3
457 477 # version:1.0.0 -> Link to version named "1.0.0"
458 478 # version:"1.0 beta 2" -> Link to version named "1.0 beta 2"
459 479 # Attachments:
460 480 # attachment:file.zip -> Link to the attachment of the current object named file.zip
461 481 # Source files:
462 482 # source:some/file -> Link to the file located at /some/file in the project's repository
463 483 # source:some/file@52 -> Link to the file's revision 52
464 484 # source:some/file#L120 -> Link to line 120 of the file
465 485 # source:some/file@52#L120 -> Link to line 120 of the file's revision 52
466 486 # export:some/file -> Force the download of the file
467 487 # Forum messages:
468 488 # message#1218 -> Link to message with id 1218
469 489 text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|<|$)}) do |m|
470 490 leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
471 491 link = nil
472 492 if esc.nil?
473 493 if prefix.nil? && sep == 'r'
474 494 if project && (changeset = project.changesets.find_by_revision(oid))
475 495 link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
476 496 :class => 'changeset',
477 497 :title => truncate_single_line(changeset.comments, :length => 100))
478 498 end
479 499 elsif sep == '#'
480 500 oid = oid.to_i
481 501 case prefix
482 502 when nil
483 503 if issue = Issue.visible.find_by_id(oid, :include => :status)
484 504 link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid},
485 505 :class => (issue.closed? ? 'issue closed' : 'issue'),
486 506 :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
487 507 link = content_tag('del', link) if issue.closed?
488 508 end
489 509 when 'document'
490 510 if document = Document.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current))
491 511 link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
492 512 :class => 'document'
493 513 end
494 514 when 'version'
495 515 if version = Version.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current))
496 516 link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
497 517 :class => 'version'
498 518 end
499 519 when 'message'
500 520 if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current))
501 521 link = link_to h(truncate(message.subject, :length => 60)), {:only_path => only_path,
502 522 :controller => 'messages',
503 523 :action => 'show',
504 524 :board_id => message.board,
505 525 :id => message.root,
506 526 :anchor => (message.parent ? "message-#{message.id}" : nil)},
507 527 :class => 'message'
508 528 end
509 529 end
510 530 elsif sep == ':'
511 531 # removes the double quotes if any
512 532 name = oid.gsub(%r{^"(.*)"$}, "\\1")
513 533 case prefix
514 534 when 'document'
515 535 if project && document = project.documents.find_by_title(name)
516 536 link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
517 537 :class => 'document'
518 538 end
519 539 when 'version'
520 540 if project && version = project.versions.find_by_name(name)
521 541 link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
522 542 :class => 'version'
523 543 end
524 544 when 'commit'
525 545 if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"]))
526 546 link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
527 547 :class => 'changeset',
528 548 :title => truncate_single_line(changeset.comments, :length => 100)
529 549 end
530 550 when 'source', 'export'
531 551 if project && project.repository
532 552 name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
533 553 path, rev, anchor = $1, $3, $5
534 554 link = link_to h("#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project,
535 555 :path => to_path_param(path),
536 556 :rev => rev,
537 557 :anchor => anchor,
538 558 :format => (prefix == 'export' ? 'raw' : nil)},
539 559 :class => (prefix == 'export' ? 'source download' : 'source')
540 560 end
541 561 when 'attachment'
542 562 if attachments && attachment = attachments.detect {|a| a.filename == name }
543 563 link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
544 564 :class => 'attachment'
545 565 end
546 566 end
547 567 end
548 568 end
549 569 leading + (link || "#{prefix}#{sep}#{oid}")
550 570 end
551 571
552 572 text
553 573 end
554 574
555 575 # Same as Rails' simple_format helper without using paragraphs
556 576 def simple_format_without_paragraph(text)
557 577 text.to_s.
558 578 gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
559 579 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
560 580 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
561 581 end
562 582
563 583 def lang_options_for_select(blank=true)
564 584 (blank ? [["(auto)", ""]] : []) +
565 585 valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
566 586 end
567 587
568 588 def label_tag_for(name, option_tags = nil, options = {})
569 589 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
570 590 content_tag("label", label_text)
571 591 end
572 592
573 593 def labelled_tabular_form_for(name, object, options, &proc)
574 594 options[:html] ||= {}
575 595 options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
576 596 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
577 597 end
578 598
579 599 def back_url_hidden_field_tag
580 600 back_url = params[:back_url] || request.env['HTTP_REFERER']
581 601 back_url = CGI.unescape(back_url.to_s)
582 602 hidden_field_tag('back_url', CGI.escape(back_url)) unless back_url.blank?
583 603 end
584 604
585 605 def check_all_links(form_name)
586 606 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
587 607 " | " +
588 608 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
589 609 end
590 610
591 611 def progress_bar(pcts, options={})
592 612 pcts = [pcts, pcts] unless pcts.is_a?(Array)
593 613 pcts[1] = pcts[1] - pcts[0]
594 614 pcts << (100 - pcts[1] - pcts[0])
595 615 width = options[:width] || '100px;'
596 616 legend = options[:legend] || ''
597 617 content_tag('table',
598 618 content_tag('tr',
599 619 (pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0].floor}%;", :class => 'closed') : '') +
600 620 (pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1].floor}%;", :class => 'done') : '') +
601 621 (pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2].floor}%;", :class => 'todo') : '')
602 622 ), :class => 'progress', :style => "width: #{width};") +
603 623 content_tag('p', legend, :class => 'pourcent')
604 624 end
605 625
606 626 def context_menu_link(name, url, options={})
607 627 options[:class] ||= ''
608 628 if options.delete(:selected)
609 629 options[:class] << ' icon-checked disabled'
610 630 options[:disabled] = true
611 631 end
612 632 if options.delete(:disabled)
613 633 options.delete(:method)
614 634 options.delete(:confirm)
615 635 options.delete(:onclick)
616 636 options[:class] << ' disabled'
617 637 url = '#'
618 638 end
619 639 link_to name, url, options
620 640 end
621 641
622 642 def calendar_for(field_id)
623 643 include_calendar_headers_tags
624 644 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
625 645 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
626 646 end
627 647
628 648 def include_calendar_headers_tags
629 649 unless @calendar_headers_tags_included
630 650 @calendar_headers_tags_included = true
631 651 content_for :header_tags do
632 652 javascript_include_tag('calendar/calendar') +
633 653 javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
634 654 javascript_include_tag('calendar/calendar-setup') +
635 655 stylesheet_link_tag('calendar')
636 656 end
637 657 end
638 658 end
639 659
640 660 def content_for(name, content = nil, &block)
641 661 @has_content ||= {}
642 662 @has_content[name] = true
643 663 super(name, content, &block)
644 664 end
645 665
646 666 def has_content?(name)
647 667 (@has_content && @has_content[name]) || false
648 668 end
649 669
650 670 # Returns the avatar image tag for the given +user+ if avatars are enabled
651 671 # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
652 672 def avatar(user, options = { })
653 673 if Setting.gravatar_enabled?
654 674 options.merge!({:ssl => Setting.protocol == 'https'})
655 675 email = nil
656 676 if user.respond_to?(:mail)
657 677 email = user.mail
658 678 elsif user.to_s =~ %r{<(.+?)>}
659 679 email = $1
660 680 end
661 681 return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil
662 682 end
663 683 end
664 684
665 685 private
666 686
667 687 def wiki_helper
668 688 helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
669 689 extend helper
670 690 return self
671 691 end
672 692
673 693 def link_to_remote_content_update(text, url_params)
674 694 link_to_remote(text,
675 695 {:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'},
676 696 {:href => url_for(:params => url_params)}
677 697 )
678 698 end
679 699
680 700 end
@@ -1,199 +1,199
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module IssuesHelper
19 19 include ApplicationHelper
20 20
21 21 def render_issue_tooltip(issue)
22 22 @cached_label_start_date ||= l(:field_start_date)
23 23 @cached_label_due_date ||= l(:field_due_date)
24 24 @cached_label_assigned_to ||= l(:field_assigned_to)
25 25 @cached_label_priority ||= l(:field_priority)
26 26
27 link_to_issue(issue) + ": #{h(issue.subject)}<br /><br />" +
27 link_to_issue(issue) + "<br /><br />" +
28 28 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
29 29 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
30 30 "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
31 31 "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
32 32 end
33 33
34 34 def render_custom_fields_rows(issue)
35 35 return if issue.custom_field_values.empty?
36 36 ordered_values = []
37 37 half = (issue.custom_field_values.size / 2.0).ceil
38 38 half.times do |i|
39 39 ordered_values << issue.custom_field_values[i]
40 40 ordered_values << issue.custom_field_values[i + half]
41 41 end
42 42 s = "<tr>\n"
43 43 n = 0
44 44 ordered_values.compact.each do |value|
45 45 s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
46 46 s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
47 47 n += 1
48 48 end
49 49 s << "</tr>\n"
50 50 s
51 51 end
52 52
53 53 def sidebar_queries
54 54 unless @sidebar_queries
55 55 # User can see public queries and his own queries
56 56 visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
57 57 # Project specific queries and global queries
58 58 visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
59 59 @sidebar_queries = Query.find(:all,
60 60 :select => 'id, name',
61 61 :order => "name ASC",
62 62 :conditions => visible.conditions)
63 63 end
64 64 @sidebar_queries
65 65 end
66 66
67 67 def show_detail(detail, no_html=false)
68 68 case detail.property
69 69 when 'attr'
70 70 label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)
71 71 case detail.prop_key
72 72 when 'due_date', 'start_date'
73 73 value = format_date(detail.value.to_date) if detail.value
74 74 old_value = format_date(detail.old_value.to_date) if detail.old_value
75 75 when 'project_id'
76 76 p = Project.find_by_id(detail.value) and value = p.name if detail.value
77 77 p = Project.find_by_id(detail.old_value) and old_value = p.name if detail.old_value
78 78 when 'status_id'
79 79 s = IssueStatus.find_by_id(detail.value) and value = s.name if detail.value
80 80 s = IssueStatus.find_by_id(detail.old_value) and old_value = s.name if detail.old_value
81 81 when 'tracker_id'
82 82 t = Tracker.find_by_id(detail.value) and value = t.name if detail.value
83 83 t = Tracker.find_by_id(detail.old_value) and old_value = t.name if detail.old_value
84 84 when 'assigned_to_id'
85 85 u = User.find_by_id(detail.value) and value = u.name if detail.value
86 86 u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value
87 87 when 'priority_id'
88 88 e = IssuePriority.find_by_id(detail.value) and value = e.name if detail.value
89 89 e = IssuePriority.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
90 90 when 'category_id'
91 91 c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
92 92 c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
93 93 when 'fixed_version_id'
94 94 v = Version.find_by_id(detail.value) and value = v.name if detail.value
95 95 v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
96 96 when 'estimated_hours'
97 97 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
98 98 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
99 99 end
100 100 when 'cf'
101 101 custom_field = CustomField.find_by_id(detail.prop_key)
102 102 if custom_field
103 103 label = custom_field.name
104 104 value = format_value(detail.value, custom_field.field_format) if detail.value
105 105 old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
106 106 end
107 107 when 'attachment'
108 108 label = l(:label_attachment)
109 109 end
110 110 call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })
111 111
112 112 label ||= detail.prop_key
113 113 value ||= detail.value
114 114 old_value ||= detail.old_value
115 115
116 116 unless no_html
117 117 label = content_tag('strong', label)
118 118 old_value = content_tag("i", h(old_value)) if detail.old_value
119 119 old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
120 120 if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
121 121 # Link to the attachment if it has not been removed
122 122 value = link_to_attachment(a)
123 123 else
124 124 value = content_tag("i", h(value)) if value
125 125 end
126 126 end
127 127
128 128 if !detail.value.blank?
129 129 case detail.property
130 130 when 'attr', 'cf'
131 131 if !detail.old_value.blank?
132 132 l(:text_journal_changed, :label => label, :old => old_value, :new => value)
133 133 else
134 134 l(:text_journal_set_to, :label => label, :value => value)
135 135 end
136 136 when 'attachment'
137 137 l(:text_journal_added, :label => label, :value => value)
138 138 end
139 139 else
140 140 l(:text_journal_deleted, :label => label, :old => old_value)
141 141 end
142 142 end
143 143
144 144 def issues_to_csv(issues, project = nil)
145 145 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
146 146 decimal_separator = l(:general_csv_decimal_separator)
147 147 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
148 148 # csv header fields
149 149 headers = [ "#",
150 150 l(:field_status),
151 151 l(:field_project),
152 152 l(:field_tracker),
153 153 l(:field_priority),
154 154 l(:field_subject),
155 155 l(:field_assigned_to),
156 156 l(:field_category),
157 157 l(:field_fixed_version),
158 158 l(:field_author),
159 159 l(:field_start_date),
160 160 l(:field_due_date),
161 161 l(:field_done_ratio),
162 162 l(:field_estimated_hours),
163 163 l(:field_created_on),
164 164 l(:field_updated_on)
165 165 ]
166 166 # Export project custom fields if project is given
167 167 # otherwise export custom fields marked as "For all projects"
168 168 custom_fields = project.nil? ? IssueCustomField.for_all : project.all_issue_custom_fields
169 169 custom_fields.each {|f| headers << f.name}
170 170 # Description in the last column
171 171 headers << l(:field_description)
172 172 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
173 173 # csv lines
174 174 issues.each do |issue|
175 175 fields = [issue.id,
176 176 issue.status.name,
177 177 issue.project.name,
178 178 issue.tracker.name,
179 179 issue.priority.name,
180 180 issue.subject,
181 181 issue.assigned_to,
182 182 issue.category,
183 183 issue.fixed_version,
184 184 issue.author.name,
185 185 format_date(issue.start_date),
186 186 format_date(issue.due_date),
187 187 issue.done_ratio,
188 188 issue.estimated_hours.to_s.gsub('.', decimal_separator),
189 189 format_time(issue.created_on),
190 190 format_time(issue.updated_on)
191 191 ]
192 192 custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
193 193 fields << issue.description
194 194 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
195 195 end
196 196 end
197 197 export
198 198 end
199 199 end
@@ -1,173 +1,173
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module TimelogHelper
19 19 include ApplicationHelper
20 20
21 21 def render_timelog_breadcrumb
22 22 links = []
23 23 links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil})
24 24 links << link_to(h(@project), {:project_id => @project, :issue_id => nil}) if @project
25 links << link_to_issue(@issue) if @issue
25 links << link_to_issue(@issue, :subject => false) if @issue
26 26 breadcrumb links
27 27 end
28 28
29 29 # Returns a collection of activities for a select field. time_entry
30 30 # is optional and will be used to check if the selected TimeEntryActivity
31 31 # is active.
32 32 def activity_collection_for_select_options(time_entry=nil, project=nil)
33 33 project ||= @project
34 34 if project.nil?
35 35 activities = TimeEntryActivity.active
36 36 else
37 37 activities = project.activities
38 38 end
39 39
40 40 collection = []
41 41 if time_entry && time_entry.activity && !time_entry.activity.active?
42 42 collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ]
43 43 else
44 44 collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
45 45 end
46 46 activities.each { |a| collection << [a.name, a.id] }
47 47 collection
48 48 end
49 49
50 50 def select_hours(data, criteria, value)
51 51 if value.to_s.empty?
52 52 data.select {|row| row[criteria].blank? }
53 53 else
54 54 data.select {|row| row[criteria] == value}
55 55 end
56 56 end
57 57
58 58 def sum_hours(data)
59 59 sum = 0
60 60 data.each do |row|
61 61 sum += row['hours'].to_f
62 62 end
63 63 sum
64 64 end
65 65
66 66 def options_for_period_select(value)
67 67 options_for_select([[l(:label_all_time), 'all'],
68 68 [l(:label_today), 'today'],
69 69 [l(:label_yesterday), 'yesterday'],
70 70 [l(:label_this_week), 'current_week'],
71 71 [l(:label_last_week), 'last_week'],
72 72 [l(:label_last_n_days, 7), '7_days'],
73 73 [l(:label_this_month), 'current_month'],
74 74 [l(:label_last_month), 'last_month'],
75 75 [l(:label_last_n_days, 30), '30_days'],
76 76 [l(:label_this_year), 'current_year']],
77 77 value)
78 78 end
79 79
80 80 def entries_to_csv(entries)
81 81 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
82 82 decimal_separator = l(:general_csv_decimal_separator)
83 83 custom_fields = TimeEntryCustomField.find(:all)
84 84 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
85 85 # csv header fields
86 86 headers = [l(:field_spent_on),
87 87 l(:field_user),
88 88 l(:field_activity),
89 89 l(:field_project),
90 90 l(:field_issue),
91 91 l(:field_tracker),
92 92 l(:field_subject),
93 93 l(:field_hours),
94 94 l(:field_comments)
95 95 ]
96 96 # Export custom fields
97 97 headers += custom_fields.collect(&:name)
98 98
99 99 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
100 100 # csv lines
101 101 entries.each do |entry|
102 102 fields = [format_date(entry.spent_on),
103 103 entry.user,
104 104 entry.activity,
105 105 entry.project,
106 106 (entry.issue ? entry.issue.id : nil),
107 107 (entry.issue ? entry.issue.tracker : nil),
108 108 (entry.issue ? entry.issue.subject : nil),
109 109 entry.hours.to_s.gsub('.', decimal_separator),
110 110 entry.comments
111 111 ]
112 112 fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
113 113
114 114 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
115 115 end
116 116 end
117 117 export
118 118 end
119 119
120 120 def format_criteria_value(criteria, value)
121 121 value.blank? ? l(:label_none) : ((k = @available_criterias[criteria][:klass]) ? k.find_by_id(value.to_i) : format_value(value, @available_criterias[criteria][:format]))
122 122 end
123 123
124 124 def report_to_csv(criterias, periods, hours)
125 125 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
126 126 # Column headers
127 127 headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) }
128 128 headers += periods
129 129 headers << l(:label_total)
130 130 csv << headers.collect {|c| to_utf8(c) }
131 131 # Content
132 132 report_criteria_to_csv(csv, criterias, periods, hours)
133 133 # Total row
134 134 row = [ l(:label_total) ] + [''] * (criterias.size - 1)
135 135 total = 0
136 136 periods.each do |period|
137 137 sum = sum_hours(select_hours(hours, @columns, period.to_s))
138 138 total += sum
139 139 row << (sum > 0 ? "%.2f" % sum : '')
140 140 end
141 141 row << "%.2f" %total
142 142 csv << row
143 143 end
144 144 export
145 145 end
146 146
147 147 def report_criteria_to_csv(csv, criterias, periods, hours, level=0)
148 148 hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value|
149 149 hours_for_value = select_hours(hours, criterias[level], value)
150 150 next if hours_for_value.empty?
151 151 row = [''] * level
152 152 row << to_utf8(format_criteria_value(criterias[level], value))
153 153 row += [''] * (criterias.length - level - 1)
154 154 total = 0
155 155 periods.each do |period|
156 156 sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s))
157 157 total += sum
158 158 row << (sum > 0 ? "%.2f" % sum : '')
159 159 end
160 160 row << "%.2f" %total
161 161 csv << row
162 162
163 163 if criterias.length > level + 1
164 164 report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1)
165 165 end
166 166 end
167 167 end
168 168
169 169 def to_utf8(s)
170 170 @ic ||= Iconv.new(l(:general_csv_encoding), 'UTF-8')
171 171 begin; @ic.iconv(s.to_s); rescue; s.to_s; end
172 172 end
173 173 end
@@ -1,39 +1,39
1 1 <table class="cal">
2 2 <thead>
3 3 <tr><td></td><% 7.times do |i| %><th><%= day_name( (calendar.first_wday+i)%7 ) %></th><% end %></tr>
4 4 </thead>
5 5 <tbody>
6 6 <tr>
7 7 <% day = calendar.startdt
8 8 while day <= calendar.enddt %>
9 9 <%= "<th>#{day.cweek}</th>" if day.cwday == calendar.first_wday %>
10 10 <td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>">
11 11 <p class="day-num"><%= day.day %></p>
12 12 <% calendar.events_on(day).each do |i| %>
13 13 <% if i.is_a? Issue %>
14 14 <div class="<%= i.css_classes %> tooltip">
15 15 <%= if day == i.start_date && day == i.due_date
16 16 image_tag('arrow_bw.png')
17 17 elsif day == i.start_date
18 18 image_tag('arrow_from.png')
19 19 elsif day == i.due_date
20 20 image_tag('arrow_to.png')
21 21 end %>
22 22 <%= h("#{i.project} -") unless @project && @project == i.project %>
23 <%= link_to_issue i %>: <%= h(truncate(i.subject, :length => 30)) %>
23 <%= link_to_issue i, :truncate => 30 %>
24 24 <span class="tip"><%= render_issue_tooltip i %></span>
25 25 </div>
26 26 <% else %>
27 27 <span class="icon icon-package">
28 28 <%= h("#{i.project} -") unless @project && @project == i.project %>
29 29 <%= link_to_version i%>
30 30 </span>
31 31 <% end %>
32 32 <% end %>
33 33 </td>
34 34 <%= '</tr><tr>' if day.cwday==calendar.last_wday and day!=calendar.enddt %>
35 35 <% day = day + 1
36 36 end %>
37 37 </tr>
38 38 </tbody>
39 39 </table>
@@ -1,32 +1,33
1 1 <div class="contextual">
2 2 <% if authorize_for('issue_relations', 'new') %>
3 3 <%= toggle_link l(:button_add), 'new-relation-form'%>
4 4 <% end %>
5 5 </div>
6 6
7 7 <p><strong><%=l(:label_related_issues)%></strong></p>
8 8
9 9 <% if @issue.relations.any? %>
10 10 <table style="width:100%">
11 11 <% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %>
12 12 <tr>
13 13 <td><%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
14 <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> <%= link_to_issue relation.other_issue(@issue) %></td>
15 <td><%=h relation.other_issue(@issue).subject %></td>
14 <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %>
15 <%= link_to_issue relation.other_issue(@issue) %>
16 </td>
16 17 <td><%= relation.other_issue(@issue).status.name %></td>
17 18 <td><%= format_date(relation.other_issue(@issue).start_date) %></td>
18 19 <td><%= format_date(relation.other_issue(@issue).due_date) %></td>
19 20 <td><%= link_to_remote(image_tag('delete.png'), { :url => {:controller => 'issue_relations', :action => 'destroy', :issue_id => @issue, :id => relation},
20 21 :method => :post
21 22 }, :title => l(:label_relation_delete)) if authorize_for('issue_relations', 'destroy') %></td>
22 23 </tr>
23 24 <% end %>
24 25 </table>
25 26 <% end %>
26 27
27 28 <% remote_form_for(:relation, @relation,
28 29 :url => {:controller => 'issue_relations', :action => 'new', :issue_id => @issue},
29 30 :method => :post,
30 31 :html => {:id => 'new-relation-form', :style => (@relation ? '' : 'display: none;')}) do |f| %>
31 32 <%= render :partial => 'issue_relations/form', :locals => {:f => f}%>
32 33 <% end %>
@@ -1,251 +1,251
1 1 <h2><%= l(:label_gantt) %></h2>
2 2
3 3 <% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
4 4 <fieldset id="filters" class="collapsible">
5 5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 6 <div>
7 7 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
8 8 </div>
9 9 </fieldset>
10 10
11 11 <p style="float:right;">
12 12 <%= if @gantt.zoom < 4
13 13 link_to_remote image_tag('zoom_in.png'), {:url => @gantt.params.merge(:zoom => (@gantt.zoom+1)), :update => 'content'}, {:href => url_for(@gantt.params.merge(:zoom => (@gantt.zoom+1)))}
14 14 else
15 15 image_tag 'zoom_in_g.png'
16 16 end %>
17 17 <%= if @gantt.zoom > 1
18 18 link_to_remote image_tag('zoom_out.png'), {:url => @gantt.params.merge(:zoom => (@gantt.zoom-1)), :update => 'content'}, {:href => url_for(@gantt.params.merge(:zoom => (@gantt.zoom-1)))}
19 19 else
20 20 image_tag 'zoom_out_g.png'
21 21 end %>
22 22 </p>
23 23
24 24 <p class="buttons">
25 25 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
26 26 <%= l(:label_months_from) %>
27 27 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
28 28 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
29 29 <%= hidden_field_tag 'zoom', @gantt.zoom %>
30 30
31 31 <%= link_to_remote l(:button_apply),
32 32 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
33 33 :update => "content",
34 34 :with => "Form.serialize('query_form')"
35 35 }, :class => 'icon icon-checked' %>
36 36
37 37 <%= link_to_remote l(:button_clear),
38 38 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
39 39 :update => "content",
40 40 }, :class => 'icon icon-reload' if @query.new_record? %>
41 41 </p>
42 42 <% end %>
43 43
44 44 <%= error_messages_for 'query' %>
45 45 <% if @query.valid? %>
46 46 <% zoom = 1
47 47 @gantt.zoom.times { zoom = zoom * 2 }
48 48
49 49 subject_width = 330
50 50 header_heigth = 18
51 51
52 52 headers_height = header_heigth
53 53 show_weeks = false
54 54 show_days = false
55 55
56 56 if @gantt.zoom >1
57 57 show_weeks = true
58 58 headers_height = 2*header_heigth
59 59 if @gantt.zoom > 2
60 60 show_days = true
61 61 headers_height = 3*header_heigth
62 62 end
63 63 end
64 64
65 65 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
66 66 g_height = [(20 * @gantt.events.length + 6)+150, 206].max
67 67 t_height = g_height + headers_height
68 68 %>
69 69
70 70 <table width="100%" style="border:0; border-collapse: collapse;">
71 71 <tr>
72 72 <td style="width:<%= subject_width %>px; padding:0px;">
73 73
74 74 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
75 75 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
76 76 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
77 77 <%
78 78 #
79 79 # Tasks subjects
80 80 #
81 81 top = headers_height + 8
82 82 @gantt.events.each do |i| %>
83 83 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
84 84 <% if i.is_a? Issue %>
85 85 <%= h("#{i.project} -") unless @project && @project == i.project %>
86 <%= link_to_issue i %>: <%=h i.subject %>
86 <%= link_to_issue i %>
87 87 <% else %>
88 88 <span class="icon icon-package">
89 89 <%= h("#{i.project} -") unless @project && @project == i.project %>
90 90 <%= link_to_version i %>
91 91 </span>
92 92 <% end %>
93 93 </small></div>
94 94 <% top = top + 20
95 95 end %>
96 96 </div>
97 97 </td>
98 98 <td>
99 99
100 100 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
101 101 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
102 102 <%
103 103 #
104 104 # Months headers
105 105 #
106 106 month_f = @gantt.date_from
107 107 left = 0
108 108 height = (show_weeks ? header_heigth : header_heigth + g_height)
109 109 @gantt.months.times do
110 110 width = ((month_f >> 1) - month_f) * zoom - 1
111 111 %>
112 112 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
113 113 <%= link_to "#{month_f.year}-#{month_f.month}", @gantt.params.merge(:year => month_f.year, :month => month_f.month), :title => "#{month_name(month_f.month)} #{month_f.year}"%>
114 114 </div>
115 115 <%
116 116 left = left + width + 1
117 117 month_f = month_f >> 1
118 118 end %>
119 119
120 120 <%
121 121 #
122 122 # Weeks headers
123 123 #
124 124 if show_weeks
125 125 left = 0
126 126 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
127 127 if @gantt.date_from.cwday == 1
128 128 # @date_from is monday
129 129 week_f = @gantt.date_from
130 130 else
131 131 # find next monday after @date_from
132 132 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
133 133 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
134 134 %>
135 135 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
136 136 <%
137 137 left = left + width+1
138 138 end %>
139 139 <%
140 140 while week_f <= @gantt.date_to
141 141 width = (week_f + 6 <= @gantt.date_to) ? 7 * zoom -1 : (@gantt.date_to - week_f + 1) * zoom-1
142 142 %>
143 143 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
144 144 <small><%= week_f.cweek if width >= 16 %></small>
145 145 </div>
146 146 <%
147 147 left = left + width+1
148 148 week_f = week_f+7
149 149 end
150 150 end %>
151 151
152 152 <%
153 153 #
154 154 # Days headers
155 155 #
156 156 if show_days
157 157 left = 0
158 158 height = g_height + header_heigth - 1
159 159 wday = @gantt.date_from.cwday
160 160 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
161 161 width = zoom - 1
162 162 %>
163 163 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
164 164 <%= day_name(wday).first %>
165 165 </div>
166 166 <%
167 167 left = left + width+1
168 168 wday = wday + 1
169 169 wday = 1 if wday > 7
170 170 end
171 171 end %>
172 172
173 173 <%
174 174 #
175 175 # Tasks
176 176 #
177 177 top = headers_height + 10
178 178 @gantt.events.each do |i|
179 179 if i.is_a? Issue
180 180 i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
181 181 i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
182 182
183 183 i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
184 184 i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
185 185 i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
186 186
187 187 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
188 188
189 189 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
190 190 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
191 191 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
192 192 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
193 193 %>
194 194 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div>
195 195 <% if l_width > 0 %>
196 196 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div>
197 197 <% end %>
198 198 <% if d_width > 0 %>
199 199 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div>
200 200 <% end %>
201 201 <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
202 202 <%= i.status.name %>
203 203 <%= (i.done_ratio).to_i %>%
204 204 </div>
205 205 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
206 206 <span class="tip">
207 207 <%= render_issue_tooltip i %>
208 208 </span></div>
209 209 <% else
210 210 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
211 211 %>
212 212 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
213 213 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
214 214 <%= h("#{i.project} -") unless @project && @project == i.project %>
215 215 <strong><%=h i %></strong>
216 216 </div>
217 217 <% end %>
218 218 <% top = top + 20
219 219 end %>
220 220
221 221 <%
222 222 #
223 223 # Today red line (excluded from cache)
224 224 #
225 225 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
226 226 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@gantt.date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
227 227 <% end %>
228 228
229 229 </div>
230 230 </td>
231 231 </tr>
232 232 </table>
233 233
234 234 <table width="100%">
235 235 <tr>
236 236 <td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => @gantt.params_previous, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td>
237 237 <td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => @gantt.params_next, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td>
238 238 </tr>
239 239 </table>
240 240
241 241 <% other_formats_links do |f| %>
242 242 <%= f.link_to 'PDF', :url => @gantt.params %>
243 243 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
244 244 <% end %>
245 245 <% end # query.valid? %>
246 246
247 247 <% content_for :sidebar do %>
248 248 <%= render :partial => 'issues/sidebar' %>
249 249 <% end %>
250 250
251 251 <% html_title(l(:label_gantt)) -%>
@@ -1,52 +1,52
1 1 <h3><%=l(:label_spent_time)%> (<%= l(:label_last_n_days, 7) %>)</h3>
2 2 <%
3 3 entries = TimeEntry.find(:all,
4 4 :conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today],
5 5 :include => [:activity, :project, {:issue => [:tracker, :status]}],
6 6 :order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC")
7 7 entries_by_day = entries.group_by(&:spent_on)
8 8 %>
9 9
10 10 <div class="total-hours">
11 11 <p><%= l(:label_total) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
12 12 </div>
13 13
14 14 <% if entries.any? %>
15 15 <table class="list time-entries">
16 16 <thead>
17 17 <th><%= l(:label_activity) %></th>
18 18 <th><%= l(:label_project) %></th>
19 19 <th><%= l(:field_comments) %></th>
20 20 <th><%= l(:field_hours) %></th>
21 21 <th></th>
22 22 </thead>
23 23 <tbody>
24 24 <% entries_by_day.keys.sort.reverse.each do |day| %>
25 25 <tr class="odd">
26 26 <td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
27 27 <td colspan="2"></td>
28 28 <td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
29 29 <td></td>
30 30 </tr>
31 31 <% entries_by_day[day].each do |entry| -%>
32 32 <tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;">
33 33 <td class="activity"><%=h entry.activity %></td>
34 <td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :title => h("#{entry.issue.subject} (#{entry.issue.status})")) if entry.issue %></td>
34 <td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
35 35 <td class="comments"><%=h entry.comments %></td>
36 36 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
37 37 <td align="center">
38 38 <% if entry.editable_by?(@user) -%>
39 39 <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
40 40 :title => l(:button_edit) %>
41 41 <%= link_to image_tag('delete.png'), {:controller => 'timelog', :action => 'destroy', :id => entry},
42 42 :confirm => l(:text_are_you_sure),
43 43 :method => :post,
44 44 :title => l(:button_delete) %>
45 45 <% end -%>
46 46 </td>
47 47 </tr>
48 48 <% end -%>
49 49 <% end -%>
50 50 </tbody>
51 51 </table>
52 52 <% end %>
@@ -1,42 +1,42
1 1 <h2><%=l(:label_change_log)%></h2>
2 2
3 3 <% if @versions.empty? %>
4 4 <p class="nodata"><%= l(:label_no_data) %></p>
5 5 <% end %>
6 6
7 7 <% @versions.each do |version| %>
8 8 <a name="<%= version.name %>"><h3 class="icon22 icon22-package"><%= version.name %></h3></a>
9 9 <% if version.effective_date %>
10 10 <p><%= format_date(version.effective_date) %></p>
11 11 <% end %>
12 12 <p><%=h version.description %></p>
13 13 <% issues = version.fixed_issues.find(:all,
14 14 :include => [:status, :tracker],
15 15 :conditions => ["#{IssueStatus.table_name}.is_closed=? AND #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", true],
16 16 :order => "#{Tracker.table_name}.position") unless @selected_tracker_ids.empty?
17 17 issues ||= []
18 18 %>
19 19 <% if !issues.empty? %>
20 20 <ul>
21 21 <% issues.each do |issue| %>
22 <li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
22 <li><%= link_to_issue(issue) %></li>
23 23 <% end %>
24 24 </ul>
25 25 <% end %>
26 26 <% end %>
27 27
28 28 <% content_for :sidebar do %>
29 29 <% form_tag({},:method => :get) do %>
30 30 <h3><%= l(:label_change_log) %></h3>
31 31 <% @trackers.each do |tracker| %>
32 32 <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
33 33 <%= tracker.name %></label><br />
34 34 <% end %>
35 35 <p><%= submit_tag l(:button_apply), :class => 'button-small' %></p>
36 36 <% end %>
37 37
38 38 <h3><%= l(:label_version_plural) %></h3>
39 39 <% @versions.each do |version| %>
40 40 <%= link_to version.name, :anchor => version.name %><br />
41 41 <% end %>
42 42 <% end %>
@@ -1,51 +1,51
1 1 <h2><%=l(:label_roadmap)%></h2>
2 2
3 3 <% if @versions.empty? %>
4 4 <p class="nodata"><%= l(:label_no_data) %></p>
5 5 <% else %>
6 6 <div id="roadmap">
7 7 <% @versions.each do |version| %>
8 8 <%= tag 'a', :name => version.name %>
9 9 <h3 class="icon22 icon22-package"><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3>
10 10 <%= render :partial => 'versions/overview', :locals => {:version => version} %>
11 11 <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
12 12
13 13 <% issues = version.fixed_issues.find(:all,
14 14 :include => [:status, :tracker],
15 15 :conditions => ["tracker_id in (#{@selected_tracker_ids.join(',')})"],
16 16 :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") unless @selected_tracker_ids.empty?
17 17 issues ||= []
18 18 %>
19 19 <% if issues.size > 0 %>
20 20 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
21 21 <ul>
22 22 <%- issues.each do |issue| -%>
23 <li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
23 <li><%= link_to_issue(issue) %></li>
24 24 <%- end -%>
25 25 </ul>
26 26 </fieldset>
27 27 <% end %>
28 28 <%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
29 29 <% end %>
30 30 </div>
31 31 <% end %>
32 32
33 33 <% content_for :sidebar do %>
34 34 <% form_tag({}, :method => :get) do %>
35 35 <h3><%= l(:label_roadmap) %></h3>
36 36 <% @trackers.each do |tracker| %>
37 37 <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %>
38 38 <%= tracker.name %></label><br />
39 39 <% end %>
40 40 <br />
41 41 <label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label>
42 42 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
43 43 <% end %>
44 44
45 45 <h3><%= l(:label_version_plural) %></h3>
46 46 <% @versions.each do |version| %>
47 47 <%= link_to version.name, "##{version.name}" %><br />
48 48 <% end %>
49 49 <% end %>
50 50
51 51 <% html_title(l(:label_roadmap)) %>
@@ -1,59 +1,59
1 1 <div class="contextual">
2 2 &#171;
3 3 <% unless @changeset.previous.nil? -%>
4 4 <%= link_to l(:label_previous), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.previous.revision %>
5 5 <% else -%>
6 6 <%= l(:label_previous) %>
7 7 <% end -%>
8 8 |
9 9 <% unless @changeset.next.nil? -%>
10 10 <%= link_to l(:label_next), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.next.revision %>
11 11 <% else -%>
12 12 <%= l(:label_next) %>
13 13 <% end -%>
14 14 &#187;&nbsp;
15 15
16 16 <% form_tag({:controller => 'repositories', :action => 'revision', :id => @project, :rev => nil}, :method => :get) do %>
17 17 <%= text_field_tag 'rev', @rev[0,8], :size => 8 %>
18 18 <%= submit_tag 'OK', :name => nil %>
19 19 <% end %>
20 20 </div>
21 21
22 22 <h2><%= l(:label_revision) %> <%= format_revision(@changeset.revision) %></h2>
23 23
24 24 <p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %>
25 25 <span class="author"><%= authoring(@changeset.committed_on, @changeset.author) %></span></p>
26 26
27 27 <%= textilizable @changeset.comments %>
28 28
29 29 <% if @changeset.issues.visible.any? %>
30 30 <h3><%= l(:label_related_issues) %></h3>
31 31 <ul>
32 32 <% @changeset.issues.visible.each do |issue| %>
33 <li><%= link_to_issue issue %>: <%=h issue.subject %></li>
33 <li><%= link_to_issue issue %></li>
34 34 <% end %>
35 35 </ul>
36 36 <% end %>
37 37
38 38 <% if User.current.allowed_to?(:browse_repository, @project) %>
39 39 <h3><%= l(:label_attachment_plural) %></h3>
40 40 <ul id="changes-legend">
41 41 <li class="change change-A"><%= l(:label_added) %></li>
42 42 <li class="change change-M"><%= l(:label_modified) %></li>
43 43 <li class="change change-C"><%= l(:label_copied) %></li>
44 44 <li class="change change-R"><%= l(:label_renamed) %></li>
45 45 <li class="change change-D"><%= l(:label_deleted) %></li>
46 46 </ul>
47 47
48 48 <p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p>
49 49
50 50 <div class="changeset-changes">
51 51 <%= render_changeset_changes %>
52 52 </div>
53 53 <% end %>
54 54
55 55 <% content_for :header_tags do %>
56 56 <%= stylesheet_link_tag "scm" %>
57 57 <% end %>
58 58
59 59 <% html_title("#{l(:label_revision)} #{@changeset.revision}") -%>
@@ -1,41 +1,41
1 1 <table class="list time-entries">
2 2 <thead>
3 3 <tr>
4 4 <%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
5 5 <%= sort_header_tag('user', :caption => l(:label_member)) %>
6 6 <%= sort_header_tag('activity', :caption => l(:label_activity)) %>
7 7 <%= sort_header_tag('project', :caption => l(:label_project)) %>
8 8 <%= sort_header_tag('issue', :caption => l(:label_issue), :default_order => 'desc') %>
9 9 <th><%= l(:field_comments) %></th>
10 10 <%= sort_header_tag('hours', :caption => l(:field_hours)) %>
11 11 <th></th>
12 12 </tr>
13 13 </thead>
14 14 <tbody>
15 15 <% entries.each do |entry| -%>
16 16 <tr class="time-entry <%= cycle("odd", "even") %>">
17 17 <td class="spent_on"><%= format_date(entry.spent_on) %></td>
18 18 <td class="user"><%=h entry.user %></td>
19 19 <td class="activity"><%=h entry.activity %></td>
20 20 <td class="project"><%=h entry.project %></td>
21 21 <td class="subject">
22 22 <% if entry.issue -%>
23 <%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, :length => 50)) -%>
23 <%= link_to_issue entry.issue, :truncate => 50 -%>
24 24 <% end -%>
25 25 </td>
26 26 <td class="comments"><%=h entry.comments %></td>
27 27 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
28 28 <td align="center">
29 29 <% if entry.editable_by?(User.current) -%>
30 30 <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry, :project_id => nil},
31 31 :title => l(:button_edit) %>
32 32 <%= link_to image_tag('delete.png'), {:controller => 'timelog', :action => 'destroy', :id => entry, :project_id => nil},
33 33 :confirm => l(:text_are_you_sure),
34 34 :method => :post,
35 35 :title => l(:button_delete) %>
36 36 <% end -%>
37 37 </td>
38 38 </tr>
39 39 <% end -%>
40 40 </tbody>
41 41 </table>
@@ -1,51 +1,51
1 1 <div class="contextual">
2 2 <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %>
3 3 <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
4 4 </div>
5 5
6 6 <h2><%= h(@version.name) %></h2>
7 7
8 8 <div id="version-summary">
9 9 <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
10 10 <fieldset><legend><%= l(:label_time_tracking) %></legend>
11 11 <table>
12 12 <tr>
13 13 <td width="130px" align="right"><%= l(:field_estimated_hours) %></td>
14 14 <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td>
15 15 </tr>
16 16 <% if User.current.allowed_to?(:view_time_entries, @project) %>
17 17 <tr>
18 18 <td width="130px" align="right"><%= l(:label_spent_time) %></td>
19 19 <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td>
20 20 </tr>
21 21 <% end %>
22 22 </table>
23 23 </fieldset>
24 24 <% end %>
25 25
26 26 <div id="status_by">
27 27 <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %>
28 28 </div>
29 29 </div>
30 30
31 31 <div id="roadmap">
32 32 <%= render :partial => 'versions/overview', :locals => {:version => @version} %>
33 33 <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
34 34
35 35 <% issues = @version.fixed_issues.find(:all,
36 36 :include => [:status, :tracker],
37 37 :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") %>
38 38 <% if issues.size > 0 %>
39 39 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
40 40 <ul>
41 41 <% issues.each do |issue| -%>
42 <li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
42 <li><%= link_to_issue(issue) %></li>
43 43 <% end -%>
44 44 </ul>
45 45 </fieldset>
46 46 <% end %>
47 47 </div>
48 48
49 49 <%= call_hook :view_versions_show_bottom, :version => @version %>
50 50
51 51 <% html_title @version.name %>
General Comments 0
You need to be logged in to leave comments. Login now