##// END OF EJS Templates
Don't generate urls with params....
Jean-Philippe Lang -
r15248:731eadc4502f
parent child
Show More
@@ -1,58 +1,58
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2016 Jean-Philippe Lang
4 # Copyright (C) 2006-2016 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module CalendarsHelper
20 module CalendarsHelper
21 def link_to_previous_month(year, month, options={})
21 def link_to_previous_month(year, month, options={})
22 target_year, target_month = if month == 1
22 target_year, target_month = if month == 1
23 [year - 1, 12]
23 [year - 1, 12]
24 else
24 else
25 [year, month - 1]
25 [year, month - 1]
26 end
26 end
27
27
28 name = if target_month == 12
28 name = if target_month == 12
29 "#{month_name(target_month)} #{target_year}"
29 "#{month_name(target_month)} #{target_year}"
30 else
30 else
31 "#{month_name(target_month)}"
31 "#{month_name(target_month)}"
32 end
32 end
33
33
34 # \xc2\xab(utf-8) = «
34 # \xc2\xab(utf-8) = «
35 link_to_month(("\xc2\xab " + name), target_year, target_month, options)
35 link_to_month(("\xc2\xab " + name), target_year, target_month, options)
36 end
36 end
37
37
38 def link_to_next_month(year, month, options={})
38 def link_to_next_month(year, month, options={})
39 target_year, target_month = if month == 12
39 target_year, target_month = if month == 12
40 [year + 1, 1]
40 [year + 1, 1]
41 else
41 else
42 [year, month + 1]
42 [year, month + 1]
43 end
43 end
44
44
45 name = if target_month == 1
45 name = if target_month == 1
46 "#{month_name(target_month)} #{target_year}"
46 "#{month_name(target_month)} #{target_year}"
47 else
47 else
48 "#{month_name(target_month)}"
48 "#{month_name(target_month)}"
49 end
49 end
50
50
51 # \xc2\xbb(utf-8) = »
51 # \xc2\xbb(utf-8) = »
52 link_to_month((name + " \xc2\xbb"), target_year, target_month, options)
52 link_to_month((name + " \xc2\xbb"), target_year, target_month, options)
53 end
53 end
54
54
55 def link_to_month(link_name, year, month, options={})
55 def link_to_month(link_name, year, month, options={})
56 link_to(link_name, params.merge(:year => year, :month => month), options)
56 link_to(link_name, {:params => request.query_parameters.merge(:year => year, :month => month)}, options)
57 end
57 end
58 end
58 end
@@ -1,43 +1,43
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2016 Jean-Philippe Lang
4 # Copyright (C) 2006-2016 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module GanttHelper
20 module GanttHelper
21
21
22 def gantt_zoom_link(gantt, in_or_out)
22 def gantt_zoom_link(gantt, in_or_out)
23 case in_or_out
23 case in_or_out
24 when :in
24 when :in
25 if gantt.zoom < 4
25 if gantt.zoom < 4
26 link_to l(:text_zoom_in),
26 link_to l(:text_zoom_in),
27 params.merge(gantt.params.merge(:zoom => (gantt.zoom + 1))),
27 {:params => request.query_parameters.merge(gantt.params.merge(:zoom => (gantt.zoom + 1)))},
28 :class => 'icon icon-zoom-in'
28 :class => 'icon icon-zoom-in'
29 else
29 else
30 content_tag(:span, l(:text_zoom_in), :class => 'icon icon-zoom-in').html_safe
30 content_tag(:span, l(:text_zoom_in), :class => 'icon icon-zoom-in').html_safe
31 end
31 end
32
32
33 when :out
33 when :out
34 if gantt.zoom > 1
34 if gantt.zoom > 1
35 link_to l(:text_zoom_out),
35 link_to l(:text_zoom_out),
36 params.merge(gantt.params.merge(:zoom => (gantt.zoom - 1))),
36 {:params => request.query_parameters.merge(gantt.params.merge(:zoom => (gantt.zoom - 1)))},
37 :class => 'icon icon-zoom-out'
37 :class => 'icon icon-zoom-out'
38 else
38 else
39 content_tag(:span, l(:text_zoom_out), :class => 'icon icon-zoom-out').html_safe
39 content_tag(:span, l(:text_zoom_out), :class => 'icon icon-zoom-out').html_safe
40 end
40 end
41 end
41 end
42 end
42 end
43 end
43 end
@@ -1,526 +1,526
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2016 Jean-Philippe Lang
4 # Copyright (C) 2006-2016 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module IssuesHelper
20 module IssuesHelper
21 include ApplicationHelper
21 include ApplicationHelper
22 include Redmine::Export::PDF::IssuesPdfHelper
22 include Redmine::Export::PDF::IssuesPdfHelper
23
23
24 def issue_list(issues, &block)
24 def issue_list(issues, &block)
25 ancestors = []
25 ancestors = []
26 issues.each do |issue|
26 issues.each do |issue|
27 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
27 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
28 ancestors.pop
28 ancestors.pop
29 end
29 end
30 yield issue, ancestors.size
30 yield issue, ancestors.size
31 ancestors << issue unless issue.leaf?
31 ancestors << issue unless issue.leaf?
32 end
32 end
33 end
33 end
34
34
35 def grouped_issue_list(issues, query, issue_count_by_group, &block)
35 def grouped_issue_list(issues, query, issue_count_by_group, &block)
36 previous_group, first = false, true
36 previous_group, first = false, true
37 totals_by_group = query.totalable_columns.inject({}) do |h, column|
37 totals_by_group = query.totalable_columns.inject({}) do |h, column|
38 h[column] = query.total_by_group_for(column)
38 h[column] = query.total_by_group_for(column)
39 h
39 h
40 end
40 end
41 issue_list(issues) do |issue, level|
41 issue_list(issues) do |issue, level|
42 group_name = group_count = nil
42 group_name = group_count = nil
43 if query.grouped?
43 if query.grouped?
44 group = query.group_by_column.value(issue)
44 group = query.group_by_column.value(issue)
45 if first || group != previous_group
45 if first || group != previous_group
46 if group.blank? && group != false
46 if group.blank? && group != false
47 group_name = "(#{l(:label_blank_value)})"
47 group_name = "(#{l(:label_blank_value)})"
48 else
48 else
49 group_name = format_object(group)
49 group_name = format_object(group)
50 end
50 end
51 group_name ||= ""
51 group_name ||= ""
52 group_count = issue_count_by_group[group]
52 group_count = issue_count_by_group[group]
53 group_totals = totals_by_group.map {|column, t| total_tag(column, t[group] || 0)}.join(" ").html_safe
53 group_totals = totals_by_group.map {|column, t| total_tag(column, t[group] || 0)}.join(" ").html_safe
54 end
54 end
55 end
55 end
56 yield issue, level, group_name, group_count, group_totals
56 yield issue, level, group_name, group_count, group_totals
57 previous_group, first = group, false
57 previous_group, first = group, false
58 end
58 end
59 end
59 end
60
60
61 # Renders a HTML/CSS tooltip
61 # Renders a HTML/CSS tooltip
62 #
62 #
63 # To use, a trigger div is needed. This is a div with the class of "tooltip"
63 # To use, a trigger div is needed. This is a div with the class of "tooltip"
64 # that contains this method wrapped in a span with the class of "tip"
64 # that contains this method wrapped in a span with the class of "tip"
65 #
65 #
66 # <div class="tooltip"><%= link_to_issue(issue) %>
66 # <div class="tooltip"><%= link_to_issue(issue) %>
67 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
67 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
68 # </div>
68 # </div>
69 #
69 #
70 def render_issue_tooltip(issue)
70 def render_issue_tooltip(issue)
71 @cached_label_status ||= l(:field_status)
71 @cached_label_status ||= l(:field_status)
72 @cached_label_start_date ||= l(:field_start_date)
72 @cached_label_start_date ||= l(:field_start_date)
73 @cached_label_due_date ||= l(:field_due_date)
73 @cached_label_due_date ||= l(:field_due_date)
74 @cached_label_assigned_to ||= l(:field_assigned_to)
74 @cached_label_assigned_to ||= l(:field_assigned_to)
75 @cached_label_priority ||= l(:field_priority)
75 @cached_label_priority ||= l(:field_priority)
76 @cached_label_project ||= l(:field_project)
76 @cached_label_project ||= l(:field_project)
77
77
78 link_to_issue(issue) + "<br /><br />".html_safe +
78 link_to_issue(issue) + "<br /><br />".html_safe +
79 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
79 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
80 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
80 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
81 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
81 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
82 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
82 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
83 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
83 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
84 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
84 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
85 end
85 end
86
86
87 def issue_heading(issue)
87 def issue_heading(issue)
88 h("#{issue.tracker} ##{issue.id}")
88 h("#{issue.tracker} ##{issue.id}")
89 end
89 end
90
90
91 def render_issue_subject_with_tree(issue)
91 def render_issue_subject_with_tree(issue)
92 s = ''
92 s = ''
93 ancestors = issue.root? ? [] : issue.ancestors.visible.to_a
93 ancestors = issue.root? ? [] : issue.ancestors.visible.to_a
94 ancestors.each do |ancestor|
94 ancestors.each do |ancestor|
95 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
95 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
96 end
96 end
97 s << '<div>'
97 s << '<div>'
98 subject = h(issue.subject)
98 subject = h(issue.subject)
99 if issue.is_private?
99 if issue.is_private?
100 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
100 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
101 end
101 end
102 s << content_tag('h3', subject)
102 s << content_tag('h3', subject)
103 s << '</div>' * (ancestors.size + 1)
103 s << '</div>' * (ancestors.size + 1)
104 s.html_safe
104 s.html_safe
105 end
105 end
106
106
107 def render_descendants_tree(issue)
107 def render_descendants_tree(issue)
108 s = '<form><table class="list issues">'
108 s = '<form><table class="list issues">'
109 issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level|
109 issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level|
110 css = "issue issue-#{child.id} hascontextmenu #{issue.css_classes}"
110 css = "issue issue-#{child.id} hascontextmenu #{issue.css_classes}"
111 css << " idnt idnt-#{level}" if level > 0
111 css << " idnt idnt-#{level}" if level > 0
112 s << content_tag('tr',
112 s << content_tag('tr',
113 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
113 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
114 content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
114 content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
115 content_tag('td', h(child.status), :class => 'status') +
115 content_tag('td', h(child.status), :class => 'status') +
116 content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') +
116 content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') +
117 content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio'),
117 content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio'),
118 :class => css)
118 :class => css)
119 end
119 end
120 s << '</table></form>'
120 s << '</table></form>'
121 s.html_safe
121 s.html_safe
122 end
122 end
123
123
124 def issue_estimated_hours_details(issue)
124 def issue_estimated_hours_details(issue)
125 if issue.total_estimated_hours.present?
125 if issue.total_estimated_hours.present?
126 if issue.total_estimated_hours == issue.estimated_hours
126 if issue.total_estimated_hours == issue.estimated_hours
127 l_hours_short(issue.estimated_hours)
127 l_hours_short(issue.estimated_hours)
128 else
128 else
129 s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : ""
129 s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : ""
130 s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})"
130 s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})"
131 s.html_safe
131 s.html_safe
132 end
132 end
133 end
133 end
134 end
134 end
135
135
136 def issue_spent_hours_details(issue)
136 def issue_spent_hours_details(issue)
137 if issue.total_spent_hours > 0
137 if issue.total_spent_hours > 0
138 if issue.total_spent_hours == issue.spent_hours
138 if issue.total_spent_hours == issue.spent_hours
139 link_to(l_hours_short(issue.spent_hours), issue_time_entries_path(issue))
139 link_to(l_hours_short(issue.spent_hours), issue_time_entries_path(issue))
140 else
140 else
141 s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : ""
141 s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : ""
142 s << " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), issue_time_entries_path(issue)})"
142 s << " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), issue_time_entries_path(issue)})"
143 s.html_safe
143 s.html_safe
144 end
144 end
145 end
145 end
146 end
146 end
147
147
148 # Returns an array of error messages for bulk edited issues
148 # Returns an array of error messages for bulk edited issues
149 def bulk_edit_error_messages(issues)
149 def bulk_edit_error_messages(issues)
150 messages = {}
150 messages = {}
151 issues.each do |issue|
151 issues.each do |issue|
152 issue.errors.full_messages.each do |message|
152 issue.errors.full_messages.each do |message|
153 messages[message] ||= []
153 messages[message] ||= []
154 messages[message] << issue
154 messages[message] << issue
155 end
155 end
156 end
156 end
157 messages.map { |message, issues|
157 messages.map { |message, issues|
158 "#{message}: " + issues.map {|i| "##{i.id}"}.join(', ')
158 "#{message}: " + issues.map {|i| "##{i.id}"}.join(', ')
159 }
159 }
160 end
160 end
161
161
162 # Returns a link for adding a new subtask to the given issue
162 # Returns a link for adding a new subtask to the given issue
163 def link_to_new_subtask(issue)
163 def link_to_new_subtask(issue)
164 attrs = {
164 attrs = {
165 :parent_issue_id => issue
165 :parent_issue_id => issue
166 }
166 }
167 attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id')
167 attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id')
168 link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
168 link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
169 end
169 end
170
170
171 def trackers_options_for_select(issue)
171 def trackers_options_for_select(issue)
172 trackers = issue.allowed_target_trackers
172 trackers = issue.allowed_target_trackers
173 if issue.new_record? && issue.parent_issue_id.present?
173 if issue.new_record? && issue.parent_issue_id.present?
174 trackers = trackers.reject do |tracker|
174 trackers = trackers.reject do |tracker|
175 issue.tracker_id != tracker.id && tracker.disabled_core_fields.include?('parent_issue_id')
175 issue.tracker_id != tracker.id && tracker.disabled_core_fields.include?('parent_issue_id')
176 end
176 end
177 end
177 end
178 trackers.collect {|t| [t.name, t.id]}
178 trackers.collect {|t| [t.name, t.id]}
179 end
179 end
180
180
181 class IssueFieldsRows
181 class IssueFieldsRows
182 include ActionView::Helpers::TagHelper
182 include ActionView::Helpers::TagHelper
183
183
184 def initialize
184 def initialize
185 @left = []
185 @left = []
186 @right = []
186 @right = []
187 end
187 end
188
188
189 def left(*args)
189 def left(*args)
190 args.any? ? @left << cells(*args) : @left
190 args.any? ? @left << cells(*args) : @left
191 end
191 end
192
192
193 def right(*args)
193 def right(*args)
194 args.any? ? @right << cells(*args) : @right
194 args.any? ? @right << cells(*args) : @right
195 end
195 end
196
196
197 def size
197 def size
198 @left.size > @right.size ? @left.size : @right.size
198 @left.size > @right.size ? @left.size : @right.size
199 end
199 end
200
200
201 def to_html
201 def to_html
202 content =
202 content =
203 content_tag('div', @left.reduce(&:+), :class => 'splitcontentleft') +
203 content_tag('div', @left.reduce(&:+), :class => 'splitcontentleft') +
204 content_tag('div', @right.reduce(&:+), :class => 'splitcontentleft')
204 content_tag('div', @right.reduce(&:+), :class => 'splitcontentleft')
205
205
206 content_tag('div', content, :class => 'splitcontent')
206 content_tag('div', content, :class => 'splitcontent')
207 end
207 end
208
208
209 def cells(label, text, options={})
209 def cells(label, text, options={})
210 options[:class] = [options[:class] || "", 'attribute'].join(' ')
210 options[:class] = [options[:class] || "", 'attribute'].join(' ')
211 content_tag 'div',
211 content_tag 'div',
212 content_tag('div', label + ":", :class => 'label') + content_tag('div', text, :class => 'value'),
212 content_tag('div', label + ":", :class => 'label') + content_tag('div', text, :class => 'value'),
213 options
213 options
214 end
214 end
215 end
215 end
216
216
217 def issue_fields_rows
217 def issue_fields_rows
218 r = IssueFieldsRows.new
218 r = IssueFieldsRows.new
219 yield r
219 yield r
220 r.to_html
220 r.to_html
221 end
221 end
222
222
223 def render_custom_fields_rows(issue)
223 def render_custom_fields_rows(issue)
224 values = issue.visible_custom_field_values
224 values = issue.visible_custom_field_values
225 return if values.empty?
225 return if values.empty?
226 half = (values.size / 2.0).ceil
226 half = (values.size / 2.0).ceil
227 issue_fields_rows do |rows|
227 issue_fields_rows do |rows|
228 values.each_with_index do |value, i|
228 values.each_with_index do |value, i|
229 css = "cf_#{value.custom_field.id}"
229 css = "cf_#{value.custom_field.id}"
230 m = (i < half ? :left : :right)
230 m = (i < half ? :left : :right)
231 rows.send m, custom_field_name_tag(value.custom_field), show_value(value), :class => css
231 rows.send m, custom_field_name_tag(value.custom_field), show_value(value), :class => css
232 end
232 end
233 end
233 end
234 end
234 end
235
235
236 # Returns the path for updating the issue form
236 # Returns the path for updating the issue form
237 # with project as the current project
237 # with project as the current project
238 def update_issue_form_path(project, issue)
238 def update_issue_form_path(project, issue)
239 options = {:format => 'js'}
239 options = {:format => 'js'}
240 if issue.new_record?
240 if issue.new_record?
241 if project
241 if project
242 new_project_issue_path(project, options)
242 new_project_issue_path(project, options)
243 else
243 else
244 new_issue_path(options)
244 new_issue_path(options)
245 end
245 end
246 else
246 else
247 edit_issue_path(issue, options)
247 edit_issue_path(issue, options)
248 end
248 end
249 end
249 end
250
250
251 # Returns the number of descendants for an array of issues
251 # Returns the number of descendants for an array of issues
252 def issues_descendant_count(issues)
252 def issues_descendant_count(issues)
253 ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq
253 ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq
254 ids -= issues.map(&:id)
254 ids -= issues.map(&:id)
255 ids.size
255 ids.size
256 end
256 end
257
257
258 def issues_destroy_confirmation_message(issues)
258 def issues_destroy_confirmation_message(issues)
259 issues = [issues] unless issues.is_a?(Array)
259 issues = [issues] unless issues.is_a?(Array)
260 message = l(:text_issues_destroy_confirmation)
260 message = l(:text_issues_destroy_confirmation)
261
261
262 descendant_count = issues_descendant_count(issues)
262 descendant_count = issues_descendant_count(issues)
263 if descendant_count > 0
263 if descendant_count > 0
264 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
264 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
265 end
265 end
266 message
266 message
267 end
267 end
268
268
269 # Returns an array of users that are proposed as watchers
269 # Returns an array of users that are proposed as watchers
270 # on the new issue form
270 # on the new issue form
271 def users_for_new_issue_watchers(issue)
271 def users_for_new_issue_watchers(issue)
272 users = issue.watcher_users
272 users = issue.watcher_users
273 if issue.project.users.count <= 20
273 if issue.project.users.count <= 20
274 users = (users + issue.project.users.sort).uniq
274 users = (users + issue.project.users.sort).uniq
275 end
275 end
276 users
276 users
277 end
277 end
278
278
279 def sidebar_queries
279 def sidebar_queries
280 unless @sidebar_queries
280 unless @sidebar_queries
281 @sidebar_queries = IssueQuery.visible.
281 @sidebar_queries = IssueQuery.visible.
282 order("#{Query.table_name}.name ASC").
282 order("#{Query.table_name}.name ASC").
283 # Project specific queries and global queries
283 # Project specific queries and global queries
284 where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
284 where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
285 to_a
285 to_a
286 end
286 end
287 @sidebar_queries
287 @sidebar_queries
288 end
288 end
289
289
290 def query_links(title, queries)
290 def query_links(title, queries)
291 return '' if queries.empty?
291 return '' if queries.empty?
292 # links to #index on issues/show
292 # links to #index on issues/show
293 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
293 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : {}
294
294
295 content_tag('h3', title) + "\n" +
295 content_tag('h3', title) + "\n" +
296 content_tag('ul',
296 content_tag('ul',
297 queries.collect {|query|
297 queries.collect {|query|
298 css = 'query'
298 css = 'query'
299 css << ' selected' if query == @query
299 css << ' selected' if query == @query
300 content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
300 content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
301 }.join("\n").html_safe,
301 }.join("\n").html_safe,
302 :class => 'queries'
302 :class => 'queries'
303 ) + "\n"
303 ) + "\n"
304 end
304 end
305
305
306 def render_sidebar_queries
306 def render_sidebar_queries
307 out = ''.html_safe
307 out = ''.html_safe
308 out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?))
308 out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?))
309 out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?))
309 out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?))
310 out
310 out
311 end
311 end
312
312
313 def email_issue_attributes(issue, user)
313 def email_issue_attributes(issue, user)
314 items = []
314 items = []
315 %w(author status priority assigned_to category fixed_version).each do |attribute|
315 %w(author status priority assigned_to category fixed_version).each do |attribute|
316 unless issue.disabled_core_fields.include?(attribute+"_id")
316 unless issue.disabled_core_fields.include?(attribute+"_id")
317 items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
317 items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
318 end
318 end
319 end
319 end
320 issue.visible_custom_field_values(user).each do |value|
320 issue.visible_custom_field_values(user).each do |value|
321 items << "#{value.custom_field.name}: #{show_value(value, false)}"
321 items << "#{value.custom_field.name}: #{show_value(value, false)}"
322 end
322 end
323 items
323 items
324 end
324 end
325
325
326 def render_email_issue_attributes(issue, user, html=false)
326 def render_email_issue_attributes(issue, user, html=false)
327 items = email_issue_attributes(issue, user)
327 items = email_issue_attributes(issue, user)
328 if html
328 if html
329 content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
329 content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
330 else
330 else
331 items.map{|s| "* #{s}"}.join("\n")
331 items.map{|s| "* #{s}"}.join("\n")
332 end
332 end
333 end
333 end
334
334
335 # Returns the textual representation of a journal details
335 # Returns the textual representation of a journal details
336 # as an array of strings
336 # as an array of strings
337 def details_to_strings(details, no_html=false, options={})
337 def details_to_strings(details, no_html=false, options={})
338 options[:only_path] = (options[:only_path] == false ? false : true)
338 options[:only_path] = (options[:only_path] == false ? false : true)
339 strings = []
339 strings = []
340 values_by_field = {}
340 values_by_field = {}
341 details.each do |detail|
341 details.each do |detail|
342 if detail.property == 'cf'
342 if detail.property == 'cf'
343 field = detail.custom_field
343 field = detail.custom_field
344 if field && field.multiple?
344 if field && field.multiple?
345 values_by_field[field] ||= {:added => [], :deleted => []}
345 values_by_field[field] ||= {:added => [], :deleted => []}
346 if detail.old_value
346 if detail.old_value
347 values_by_field[field][:deleted] << detail.old_value
347 values_by_field[field][:deleted] << detail.old_value
348 end
348 end
349 if detail.value
349 if detail.value
350 values_by_field[field][:added] << detail.value
350 values_by_field[field][:added] << detail.value
351 end
351 end
352 next
352 next
353 end
353 end
354 end
354 end
355 strings << show_detail(detail, no_html, options)
355 strings << show_detail(detail, no_html, options)
356 end
356 end
357 if values_by_field.present?
357 if values_by_field.present?
358 multiple_values_detail = Struct.new(:property, :prop_key, :custom_field, :old_value, :value)
358 multiple_values_detail = Struct.new(:property, :prop_key, :custom_field, :old_value, :value)
359 values_by_field.each do |field, changes|
359 values_by_field.each do |field, changes|
360 if changes[:added].any?
360 if changes[:added].any?
361 detail = multiple_values_detail.new('cf', field.id.to_s, field)
361 detail = multiple_values_detail.new('cf', field.id.to_s, field)
362 detail.value = changes[:added]
362 detail.value = changes[:added]
363 strings << show_detail(detail, no_html, options)
363 strings << show_detail(detail, no_html, options)
364 end
364 end
365 if changes[:deleted].any?
365 if changes[:deleted].any?
366 detail = multiple_values_detail.new('cf', field.id.to_s, field)
366 detail = multiple_values_detail.new('cf', field.id.to_s, field)
367 detail.old_value = changes[:deleted]
367 detail.old_value = changes[:deleted]
368 strings << show_detail(detail, no_html, options)
368 strings << show_detail(detail, no_html, options)
369 end
369 end
370 end
370 end
371 end
371 end
372 strings
372 strings
373 end
373 end
374
374
375 # Returns the textual representation of a single journal detail
375 # Returns the textual representation of a single journal detail
376 def show_detail(detail, no_html=false, options={})
376 def show_detail(detail, no_html=false, options={})
377 multiple = false
377 multiple = false
378 show_diff = false
378 show_diff = false
379
379
380 case detail.property
380 case detail.property
381 when 'attr'
381 when 'attr'
382 field = detail.prop_key.to_s.gsub(/\_id$/, "")
382 field = detail.prop_key.to_s.gsub(/\_id$/, "")
383 label = l(("field_" + field).to_sym)
383 label = l(("field_" + field).to_sym)
384 case detail.prop_key
384 case detail.prop_key
385 when 'due_date', 'start_date'
385 when 'due_date', 'start_date'
386 value = format_date(detail.value.to_date) if detail.value
386 value = format_date(detail.value.to_date) if detail.value
387 old_value = format_date(detail.old_value.to_date) if detail.old_value
387 old_value = format_date(detail.old_value.to_date) if detail.old_value
388
388
389 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
389 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
390 'priority_id', 'category_id', 'fixed_version_id'
390 'priority_id', 'category_id', 'fixed_version_id'
391 value = find_name_by_reflection(field, detail.value)
391 value = find_name_by_reflection(field, detail.value)
392 old_value = find_name_by_reflection(field, detail.old_value)
392 old_value = find_name_by_reflection(field, detail.old_value)
393
393
394 when 'estimated_hours'
394 when 'estimated_hours'
395 value = l_hours_short(detail.value.to_f) unless detail.value.blank?
395 value = l_hours_short(detail.value.to_f) unless detail.value.blank?
396 old_value = l_hours_short(detail.old_value.to_f) unless detail.old_value.blank?
396 old_value = l_hours_short(detail.old_value.to_f) unless detail.old_value.blank?
397
397
398 when 'parent_id'
398 when 'parent_id'
399 label = l(:field_parent_issue)
399 label = l(:field_parent_issue)
400 value = "##{detail.value}" unless detail.value.blank?
400 value = "##{detail.value}" unless detail.value.blank?
401 old_value = "##{detail.old_value}" unless detail.old_value.blank?
401 old_value = "##{detail.old_value}" unless detail.old_value.blank?
402
402
403 when 'is_private'
403 when 'is_private'
404 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
404 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
405 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
405 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
406
406
407 when 'description'
407 when 'description'
408 show_diff = true
408 show_diff = true
409 end
409 end
410 when 'cf'
410 when 'cf'
411 custom_field = detail.custom_field
411 custom_field = detail.custom_field
412 if custom_field
412 if custom_field
413 label = custom_field.name
413 label = custom_field.name
414 if custom_field.format.class.change_as_diff
414 if custom_field.format.class.change_as_diff
415 show_diff = true
415 show_diff = true
416 else
416 else
417 multiple = custom_field.multiple?
417 multiple = custom_field.multiple?
418 value = format_value(detail.value, custom_field) if detail.value
418 value = format_value(detail.value, custom_field) if detail.value
419 old_value = format_value(detail.old_value, custom_field) if detail.old_value
419 old_value = format_value(detail.old_value, custom_field) if detail.old_value
420 end
420 end
421 end
421 end
422 when 'attachment'
422 when 'attachment'
423 label = l(:label_attachment)
423 label = l(:label_attachment)
424 when 'relation'
424 when 'relation'
425 if detail.value && !detail.old_value
425 if detail.value && !detail.old_value
426 rel_issue = Issue.visible.find_by_id(detail.value)
426 rel_issue = Issue.visible.find_by_id(detail.value)
427 value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.value}" :
427 value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.value}" :
428 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
428 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
429 elsif detail.old_value && !detail.value
429 elsif detail.old_value && !detail.value
430 rel_issue = Issue.visible.find_by_id(detail.old_value)
430 rel_issue = Issue.visible.find_by_id(detail.old_value)
431 old_value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.old_value}" :
431 old_value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.old_value}" :
432 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
432 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
433 end
433 end
434 relation_type = IssueRelation::TYPES[detail.prop_key]
434 relation_type = IssueRelation::TYPES[detail.prop_key]
435 label = l(relation_type[:name]) if relation_type
435 label = l(relation_type[:name]) if relation_type
436 end
436 end
437 call_hook(:helper_issues_show_detail_after_setting,
437 call_hook(:helper_issues_show_detail_after_setting,
438 {:detail => detail, :label => label, :value => value, :old_value => old_value })
438 {:detail => detail, :label => label, :value => value, :old_value => old_value })
439
439
440 label ||= detail.prop_key
440 label ||= detail.prop_key
441 value ||= detail.value
441 value ||= detail.value
442 old_value ||= detail.old_value
442 old_value ||= detail.old_value
443
443
444 unless no_html
444 unless no_html
445 label = content_tag('strong', label)
445 label = content_tag('strong', label)
446 old_value = content_tag("i", h(old_value)) if detail.old_value
446 old_value = content_tag("i", h(old_value)) if detail.old_value
447 if detail.old_value && detail.value.blank? && detail.property != 'relation'
447 if detail.old_value && detail.value.blank? && detail.property != 'relation'
448 old_value = content_tag("del", old_value)
448 old_value = content_tag("del", old_value)
449 end
449 end
450 if detail.property == 'attachment' && value.present? &&
450 if detail.property == 'attachment' && value.present? &&
451 atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
451 atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
452 # Link to the attachment if it has not been removed
452 # Link to the attachment if it has not been removed
453 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
453 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
454 if options[:only_path] != false && (atta.is_text? || atta.is_image?)
454 if options[:only_path] != false && (atta.is_text? || atta.is_image?)
455 value += ' '
455 value += ' '
456 value += link_to(l(:button_view),
456 value += link_to(l(:button_view),
457 { :controller => 'attachments', :action => 'show',
457 { :controller => 'attachments', :action => 'show',
458 :id => atta, :filename => atta.filename },
458 :id => atta, :filename => atta.filename },
459 :class => 'icon-only icon-magnifier',
459 :class => 'icon-only icon-magnifier',
460 :title => l(:button_view))
460 :title => l(:button_view))
461 end
461 end
462 else
462 else
463 value = content_tag("i", h(value)) if value
463 value = content_tag("i", h(value)) if value
464 end
464 end
465 end
465 end
466
466
467 if show_diff
467 if show_diff
468 s = l(:text_journal_changed_no_detail, :label => label)
468 s = l(:text_journal_changed_no_detail, :label => label)
469 unless no_html
469 unless no_html
470 diff_link = link_to 'diff',
470 diff_link = link_to 'diff',
471 diff_journal_url(detail.journal_id, :detail_id => detail.id, :only_path => options[:only_path]),
471 diff_journal_url(detail.journal_id, :detail_id => detail.id, :only_path => options[:only_path]),
472 :title => l(:label_view_diff)
472 :title => l(:label_view_diff)
473 s << " (#{ diff_link })"
473 s << " (#{ diff_link })"
474 end
474 end
475 s.html_safe
475 s.html_safe
476 elsif detail.value.present?
476 elsif detail.value.present?
477 case detail.property
477 case detail.property
478 when 'attr', 'cf'
478 when 'attr', 'cf'
479 if detail.old_value.present?
479 if detail.old_value.present?
480 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
480 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
481 elsif multiple
481 elsif multiple
482 l(:text_journal_added, :label => label, :value => value).html_safe
482 l(:text_journal_added, :label => label, :value => value).html_safe
483 else
483 else
484 l(:text_journal_set_to, :label => label, :value => value).html_safe
484 l(:text_journal_set_to, :label => label, :value => value).html_safe
485 end
485 end
486 when 'attachment', 'relation'
486 when 'attachment', 'relation'
487 l(:text_journal_added, :label => label, :value => value).html_safe
487 l(:text_journal_added, :label => label, :value => value).html_safe
488 end
488 end
489 else
489 else
490 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
490 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
491 end
491 end
492 end
492 end
493
493
494 # Find the name of an associated record stored in the field attribute
494 # Find the name of an associated record stored in the field attribute
495 def find_name_by_reflection(field, id)
495 def find_name_by_reflection(field, id)
496 unless id.present?
496 unless id.present?
497 return nil
497 return nil
498 end
498 end
499 @detail_value_name_by_reflection ||= Hash.new do |hash, key|
499 @detail_value_name_by_reflection ||= Hash.new do |hash, key|
500 association = Issue.reflect_on_association(key.first.to_sym)
500 association = Issue.reflect_on_association(key.first.to_sym)
501 name = nil
501 name = nil
502 if association
502 if association
503 record = association.klass.find_by_id(key.last)
503 record = association.klass.find_by_id(key.last)
504 if record
504 if record
505 name = record.name.force_encoding('UTF-8')
505 name = record.name.force_encoding('UTF-8')
506 end
506 end
507 end
507 end
508 hash[key] = name
508 hash[key] = name
509 end
509 end
510 @detail_value_name_by_reflection[[field, id]]
510 @detail_value_name_by_reflection[[field, id]]
511 end
511 end
512
512
513 # Renders issue children recursively
513 # Renders issue children recursively
514 def render_api_issue_children(issue, api)
514 def render_api_issue_children(issue, api)
515 return if issue.leaf?
515 return if issue.leaf?
516 api.array :children do
516 api.array :children do
517 issue.children.each do |child|
517 issue.children.each do |child|
518 api.issue(:id => child.id) do
518 api.issue(:id => child.id) do
519 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
519 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
520 api.subject child.subject
520 api.subject child.subject
521 render_api_issue_children(child, api)
521 render_api_issue_children(child, api)
522 end
522 end
523 end
523 end
524 end
524 end
525 end
525 end
526 end
526 end
@@ -1,72 +1,72
1 <h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
1 <h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
2 <p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
2 <p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
3
3
4 <div id="activity">
4 <div id="activity">
5 <% @events_by_day.keys.sort.reverse.each do |day| %>
5 <% @events_by_day.keys.sort.reverse.each do |day| %>
6 <h3><%= format_activity_day(day) %></h3>
6 <h3><%= format_activity_day(day) %></h3>
7 <dl>
7 <dl>
8 <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
8 <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
9 <dt class="<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
9 <dt class="<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
10 <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
10 <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
11 <span class="time"><%= format_time(e.event_datetime, false) %></span>
11 <span class="time"><%= format_time(e.event_datetime, false) %></span>
12 <%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
12 <%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
13 <%= link_to format_activity_title(e.event_title), e.event_url %>
13 <%= link_to format_activity_title(e.event_title), e.event_url %>
14 </dt>
14 </dt>
15 <dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
15 <dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
16 <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
16 <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
17 <% end -%>
17 <% end -%>
18 </dl>
18 </dl>
19 <% end -%>
19 <% end -%>
20 </div>
20 </div>
21
21
22 <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
22 <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
23
23
24 <span class="pagination">
24 <span class="pagination">
25 <ul class="pages">
25 <ul class="pages">
26 <li class="previous page">
26 <li class="previous page">
27 <%= link_to("\xc2\xab " + l(:label_previous),
27 <%= link_to("\xc2\xab " + l(:label_previous),
28 params.merge(:from => @date_to - @days - 1),
28 {:params => request.query_parameters.merge(:from => @date_to - @days - 1)},
29 :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1)),
29 :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1)),
30 :accesskey => accesskey(:previous)) %>
30 :accesskey => accesskey(:previous)) %>
31 </li><% unless @date_to >= User.current.today %><li class="next page">
31 </li><% unless @date_to >= User.current.today %><li class="next page">
32 <%= link_to(l(:label_next) + " \xc2\xbb",
32 <%= link_to(l(:label_next) + " \xc2\xbb",
33 params.merge(:from => @date_to + @days - 1),
33 {:params => request.query_parameters.merge(:from => @date_to + @days - 1)},
34 :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1)),
34 :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1)),
35 :accesskey => accesskey(:next)) %><% end %>
35 :accesskey => accesskey(:next)) %><% end %>
36 </li>
36 </li>
37 </ul>
37 </ul>
38 </span>
38 </span>
39 &nbsp;
39 &nbsp;
40 <% other_formats_links do |f| %>
40 <% other_formats_links do |f| %>
41 <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %>
41 <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %>
42 <% end %>
42 <% end %>
43
43
44 <% content_for :header_tags do %>
44 <% content_for :header_tags do %>
45 <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
45 <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
46 <% end %>
46 <% end %>
47
47
48 <% content_for :sidebar do %>
48 <% content_for :sidebar do %>
49 <%= form_tag({}, :method => :get) do %>
49 <%= form_tag({}, :method => :get) do %>
50 <h3><%= l(:label_activity) %></h3>
50 <h3><%= l(:label_activity) %></h3>
51 <ul>
51 <ul>
52 <% @activity.event_types.each do |t| %>
52 <% @activity.event_types.each do |t| %>
53 <li>
53 <li>
54 <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
54 <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
55 <label for="show_<%=t%>">
55 <label for="show_<%=t%>">
56 <%= link_to(l("label_#{t.singularize}_plural"),
56 <%= link_to(l("label_#{t.singularize}_plural"),
57 {"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
57 {"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
58 </label>
58 </label>
59 </li>
59 </li>
60 <% end %>
60 <% end %>
61 </ul>
61 </ul>
62 <% if @project && @project.descendants.active.any? %>
62 <% if @project && @project.descendants.active.any? %>
63 <%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
63 <%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
64 <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
64 <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
65 <% end %>
65 <% end %>
66 <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
66 <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
67 <%= hidden_field_tag('from', params[:from]) unless params[:from].blank? %>
67 <%= hidden_field_tag('from', params[:from]) unless params[:from].blank? %>
68 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
68 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
69 <% end %>
69 <% end %>
70 <% end %>
70 <% end %>
71
71
72 <% html_title(l(:label_activity), @author) -%>
72 <% html_title(l(:label_activity), @author) -%>
@@ -1,372 +1,372
1 <% @gantt.view = self %>
1 <% @gantt.view = self %>
2 <div class="contextual">
2 <div class="contextual">
3 <% if !@query.new_record? && @query.editable_by?(User.current) %>
3 <% if !@query.new_record? && @query.editable_by?(User.current) %>
4 <%= link_to l(:button_edit), edit_query_path(@query, :gantt => 1), :class => 'icon icon-edit' %>
4 <%= link_to l(:button_edit), edit_query_path(@query, :gantt => 1), :class => 'icon icon-edit' %>
5 <%= delete_link query_path(@query, :gantt => 1) %>
5 <%= delete_link query_path(@query, :gantt => 1) %>
6 <% end %>
6 <% end %>
7 </div>
7 </div>
8
8
9 <h2><%= @query.new_record? ? l(:label_gantt) : @query.name %></h2>
9 <h2><%= @query.new_record? ? l(:label_gantt) : @query.name %></h2>
10
10
11 <%= form_tag({:controller => 'gantts', :action => 'show',
11 <%= form_tag({:controller => 'gantts', :action => 'show',
12 :project_id => @project, :month => params[:month],
12 :project_id => @project, :month => params[:month],
13 :year => params[:year], :months => params[:months]},
13 :year => params[:year], :months => params[:months]},
14 :method => :get, :id => 'query_form') do %>
14 :method => :get, :id => 'query_form') do %>
15 <%= hidden_field_tag 'set_filter', '1' %>
15 <%= hidden_field_tag 'set_filter', '1' %>
16 <%= hidden_field_tag 'gantt', '1' %>
16 <%= hidden_field_tag 'gantt', '1' %>
17 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
17 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
18 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
18 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
19 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
19 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
20 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
20 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
21 </div>
21 </div>
22 </fieldset>
22 </fieldset>
23 <fieldset id="options" class="collapsible collapsed">
23 <fieldset id="options" class="collapsible collapsed">
24 <legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
24 <legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
25 <div style="display: none;">
25 <div style="display: none;">
26 <table>
26 <table>
27 <tr>
27 <tr>
28 <td>
28 <td>
29 <fieldset>
29 <fieldset>
30 <legend><%= l(:label_related_issues) %></legend>
30 <legend><%= l(:label_related_issues) %></legend>
31 <label for="draw_relations">
31 <label for="draw_relations">
32 <%= check_box 'query', 'draw_relations', :id => 'draw_relations' %>
32 <%= check_box 'query', 'draw_relations', :id => 'draw_relations' %>
33 <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
33 <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
34 <% rels.each do |rel| %>
34 <% rels.each do |rel| %>
35 <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
35 <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
36 <%= content_tag(:span, '&nbsp;&nbsp;&nbsp;'.html_safe,
36 <%= content_tag(:span, '&nbsp;&nbsp;&nbsp;'.html_safe,
37 :style => "background-color: #{color}") %>
37 :style => "background-color: #{color}") %>
38 <%= l(IssueRelation::TYPES[rel][:name]) %>
38 <%= l(IssueRelation::TYPES[rel][:name]) %>
39 <% end %>
39 <% end %>
40 </label>
40 </label>
41 </fieldset>
41 </fieldset>
42 </td>
42 </td>
43 <td>
43 <td>
44 <fieldset>
44 <fieldset>
45 <legend><%= l(:label_gantt_progress_line) %></legend>
45 <legend><%= l(:label_gantt_progress_line) %></legend>
46 <label for="draw_progress_line">
46 <label for="draw_progress_line">
47 <%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %>
47 <%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %>
48 <%= l(:label_display) %>
48 <%= l(:label_display) %>
49 </label>
49 </label>
50 </fieldset>
50 </fieldset>
51 </td>
51 </td>
52 </tr>
52 </tr>
53 </table>
53 </table>
54 </div>
54 </div>
55 </fieldset>
55 </fieldset>
56
56
57 <p class="contextual">
57 <p class="contextual">
58 <%= gantt_zoom_link(@gantt, :in) %>
58 <%= gantt_zoom_link(@gantt, :in) %>
59 <%= gantt_zoom_link(@gantt, :out) %>
59 <%= gantt_zoom_link(@gantt, :out) %>
60 </p>
60 </p>
61
61
62 <p class="buttons">
62 <p class="buttons">
63 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
63 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
64 <%= l(:label_months_from) %>
64 <%= l(:label_months_from) %>
65 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
65 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
66 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
66 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
67 <%= hidden_field_tag 'zoom', @gantt.zoom %>
67 <%= hidden_field_tag 'zoom', @gantt.zoom %>
68
68
69 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
69 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
70 :class => 'icon icon-checked' %>
70 :class => 'icon icon-checked' %>
71 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
71 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
72 :class => 'icon icon-reload' %>
72 :class => 'icon icon-reload' %>
73 <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
73 <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
74 <%= link_to_function l(:button_save),
74 <%= link_to_function l(:button_save),
75 "$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();",
75 "$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();",
76 :class => 'icon icon-save' %>
76 :class => 'icon icon-save' %>
77 <% end %>
77 <% end %>
78 </p>
78 </p>
79 <% end %>
79 <% end %>
80
80
81 <%= error_messages_for 'query' %>
81 <%= error_messages_for 'query' %>
82 <% if @query.valid? %>
82 <% if @query.valid? %>
83 <%
83 <%
84 zoom = 1
84 zoom = 1
85 @gantt.zoom.times { zoom = zoom * 2 }
85 @gantt.zoom.times { zoom = zoom * 2 }
86
86
87 subject_width = 330
87 subject_width = 330
88 header_height = 18
88 header_height = 18
89
89
90 headers_height = header_height
90 headers_height = header_height
91 show_weeks = false
91 show_weeks = false
92 show_days = false
92 show_days = false
93 show_day_num = false
93 show_day_num = false
94
94
95 if @gantt.zoom > 1
95 if @gantt.zoom > 1
96 show_weeks = true
96 show_weeks = true
97 headers_height = 2 * header_height
97 headers_height = 2 * header_height
98 if @gantt.zoom > 2
98 if @gantt.zoom > 2
99 show_days = true
99 show_days = true
100 headers_height = 3 * header_height
100 headers_height = 3 * header_height
101 if @gantt.zoom > 3
101 if @gantt.zoom > 3
102 show_day_num = true
102 show_day_num = true
103 headers_height = 4 * header_height
103 headers_height = 4 * header_height
104 end
104 end
105 end
105 end
106 end
106 end
107
107
108 # Width of the entire chart
108 # Width of the entire chart
109 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
109 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
110 @gantt.render(:top => headers_height + 8,
110 @gantt.render(:top => headers_height + 8,
111 :zoom => zoom,
111 :zoom => zoom,
112 :g_width => g_width,
112 :g_width => g_width,
113 :subject_width => subject_width)
113 :subject_width => subject_width)
114 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
114 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
115 t_height = g_height + headers_height
115 t_height = g_height + headers_height
116 %>
116 %>
117
117
118 <% if @gantt.truncated %>
118 <% if @gantt.truncated %>
119 <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
119 <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
120 <% end %>
120 <% end %>
121
121
122 <table style="width:100%; border:0; border-collapse: collapse;">
122 <table style="width:100%; border:0; border-collapse: collapse;">
123 <tr>
123 <tr>
124 <td style="width:<%= subject_width %>px; padding:0px;">
124 <td style="width:<%= subject_width %>px; padding:0px;">
125 <%
125 <%
126 style = ""
126 style = ""
127 style += "position:relative;"
127 style += "position:relative;"
128 style += "height: #{t_height + 24}px;"
128 style += "height: #{t_height + 24}px;"
129 style += "width: #{subject_width + 1}px;"
129 style += "width: #{subject_width + 1}px;"
130 %>
130 %>
131 <%= content_tag(:div, :style => style) do %>
131 <%= content_tag(:div, :style => style) do %>
132 <%
132 <%
133 style = ""
133 style = ""
134 style += "right:-2px;"
134 style += "right:-2px;"
135 style += "width: #{subject_width}px;"
135 style += "width: #{subject_width}px;"
136 style += "height: #{headers_height}px;"
136 style += "height: #{headers_height}px;"
137 style += 'background: #eee;'
137 style += 'background: #eee;'
138 %>
138 %>
139 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
139 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
140 <%
140 <%
141 style = ""
141 style = ""
142 style += "right:-2px;"
142 style += "right:-2px;"
143 style += "width: #{subject_width}px;"
143 style += "width: #{subject_width}px;"
144 style += "height: #{t_height}px;"
144 style += "height: #{t_height}px;"
145 style += 'border-left: 1px solid #c0c0c0;'
145 style += 'border-left: 1px solid #c0c0c0;'
146 style += 'overflow: hidden;'
146 style += 'overflow: hidden;'
147 %>
147 %>
148 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
148 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
149 <%= content_tag(:div, :class => "gantt_subjects") do %>
149 <%= content_tag(:div, :class => "gantt_subjects") do %>
150 <%= @gantt.subjects.html_safe %>
150 <%= @gantt.subjects.html_safe %>
151 <% end %>
151 <% end %>
152 <% end %>
152 <% end %>
153 </td>
153 </td>
154
154
155 <td>
155 <td>
156 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
156 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
157 <%
157 <%
158 style = ""
158 style = ""
159 style += "width: #{g_width - 1}px;"
159 style += "width: #{g_width - 1}px;"
160 style += "height: #{headers_height}px;"
160 style += "height: #{headers_height}px;"
161 style += 'background: #eee;'
161 style += 'background: #eee;'
162 %>
162 %>
163 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
163 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
164
164
165 <% ###### Months headers ###### %>
165 <% ###### Months headers ###### %>
166 <%
166 <%
167 month_f = @gantt.date_from
167 month_f = @gantt.date_from
168 left = 0
168 left = 0
169 height = (show_weeks ? header_height : header_height + g_height)
169 height = (show_weeks ? header_height : header_height + g_height)
170 %>
170 %>
171 <% @gantt.months.times do %>
171 <% @gantt.months.times do %>
172 <%
172 <%
173 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
173 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
174 style = ""
174 style = ""
175 style += "left: #{left}px;"
175 style += "left: #{left}px;"
176 style += "width: #{width}px;"
176 style += "width: #{width}px;"
177 style += "height: #{height}px;"
177 style += "height: #{height}px;"
178 %>
178 %>
179 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
179 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
180 <%= link_to "#{month_f.year}-#{month_f.month}",
180 <%= link_to "#{month_f.year}-#{month_f.month}",
181 @gantt.params.merge(:year => month_f.year, :month => month_f.month),
181 @gantt.params.merge(:year => month_f.year, :month => month_f.month),
182 :title => "#{month_name(month_f.month)} #{month_f.year}" %>
182 :title => "#{month_name(month_f.month)} #{month_f.year}" %>
183 <% end %>
183 <% end %>
184 <%
184 <%
185 left = left + width + 1
185 left = left + width + 1
186 month_f = month_f >> 1
186 month_f = month_f >> 1
187 %>
187 %>
188 <% end %>
188 <% end %>
189
189
190 <% ###### Weeks headers ###### %>
190 <% ###### Weeks headers ###### %>
191 <% if show_weeks %>
191 <% if show_weeks %>
192 <%
192 <%
193 left = 0
193 left = 0
194 height = (show_days ? header_height - 1 : header_height - 1 + g_height)
194 height = (show_days ? header_height - 1 : header_height - 1 + g_height)
195 %>
195 %>
196 <% if @gantt.date_from.cwday == 1 %>
196 <% if @gantt.date_from.cwday == 1 %>
197 <%
197 <%
198 # @date_from is monday
198 # @date_from is monday
199 week_f = @gantt.date_from
199 week_f = @gantt.date_from
200 %>
200 %>
201 <% else %>
201 <% else %>
202 <%
202 <%
203 # find next monday after @date_from
203 # find next monday after @date_from
204 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
204 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
205 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
205 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
206 style = ""
206 style = ""
207 style += "left: #{left}px;"
207 style += "left: #{left}px;"
208 style += "top: 19px;"
208 style += "top: 19px;"
209 style += "width: #{width}px;"
209 style += "width: #{width}px;"
210 style += "height: #{height}px;"
210 style += "height: #{height}px;"
211 %>
211 %>
212 <%= content_tag(:div, '&nbsp;'.html_safe,
212 <%= content_tag(:div, '&nbsp;'.html_safe,
213 :style => style, :class => "gantt_hdr") %>
213 :style => style, :class => "gantt_hdr") %>
214 <% left = left + width + 1 %>
214 <% left = left + width + 1 %>
215 <% end %>
215 <% end %>
216 <% while week_f <= @gantt.date_to %>
216 <% while week_f <= @gantt.date_to %>
217 <%
217 <%
218 width = ((week_f + 6 <= @gantt.date_to) ?
218 width = ((week_f + 6 <= @gantt.date_to) ?
219 7 * zoom - 1 :
219 7 * zoom - 1 :
220 (@gantt.date_to - week_f + 1) * zoom - 1).to_i
220 (@gantt.date_to - week_f + 1) * zoom - 1).to_i
221 style = ""
221 style = ""
222 style += "left: #{left}px;"
222 style += "left: #{left}px;"
223 style += "top: 19px;"
223 style += "top: 19px;"
224 style += "width: #{width}px;"
224 style += "width: #{width}px;"
225 style += "height: #{height}px;"
225 style += "height: #{height}px;"
226 %>
226 %>
227 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
227 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
228 <%= content_tag(:small) do %>
228 <%= content_tag(:small) do %>
229 <%= week_f.cweek if width >= 16 %>
229 <%= week_f.cweek if width >= 16 %>
230 <% end %>
230 <% end %>
231 <% end %>
231 <% end %>
232 <%
232 <%
233 left = left + width + 1
233 left = left + width + 1
234 week_f = week_f + 7
234 week_f = week_f + 7
235 %>
235 %>
236 <% end %>
236 <% end %>
237 <% end %>
237 <% end %>
238
238
239 <% ###### Day numbers headers ###### %>
239 <% ###### Day numbers headers ###### %>
240 <% if show_day_num %>
240 <% if show_day_num %>
241 <%
241 <%
242 left = 0
242 left = 0
243 height = g_height + header_height*2 - 1
243 height = g_height + header_height*2 - 1
244 wday = @gantt.date_from.cwday
244 wday = @gantt.date_from.cwday
245 day_num = @gantt.date_from
245 day_num = @gantt.date_from
246 %>
246 %>
247 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
247 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
248 <%
248 <%
249 width = zoom - 1
249 width = zoom - 1
250 style = ""
250 style = ""
251 style += "left:#{left}px;"
251 style += "left:#{left}px;"
252 style += "top:37px;"
252 style += "top:37px;"
253 style += "width:#{width}px;"
253 style += "width:#{width}px;"
254 style += "height:#{height}px;"
254 style += "height:#{height}px;"
255 style += "font-size:0.7em;"
255 style += "font-size:0.7em;"
256 clss = "gantt_hdr"
256 clss = "gantt_hdr"
257 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
257 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
258 %>
258 %>
259 <%= content_tag(:div, :style => style, :class => clss) do %>
259 <%= content_tag(:div, :style => style, :class => clss) do %>
260 <%= day_num.day %>
260 <%= day_num.day %>
261 <% end %>
261 <% end %>
262 <%
262 <%
263 left = left + width+1
263 left = left + width+1
264 day_num = day_num + 1
264 day_num = day_num + 1
265 wday = wday + 1
265 wday = wday + 1
266 wday = 1 if wday > 7
266 wday = 1 if wday > 7
267 %>
267 %>
268 <% end %>
268 <% end %>
269 <% end %>
269 <% end %>
270
270
271 <% ###### Days headers ####### %>
271 <% ###### Days headers ####### %>
272 <% if show_days %>
272 <% if show_days %>
273 <%
273 <%
274 left = 0
274 left = 0
275 height = g_height + header_height - 1
275 height = g_height + header_height - 1
276 top = (show_day_num ? 55 : 37)
276 top = (show_day_num ? 55 : 37)
277 wday = @gantt.date_from.cwday
277 wday = @gantt.date_from.cwday
278 %>
278 %>
279 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
279 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
280 <%
280 <%
281 width = zoom - 1
281 width = zoom - 1
282 style = ""
282 style = ""
283 style += "left: #{left}px;"
283 style += "left: #{left}px;"
284 style += "top: #{top}px;"
284 style += "top: #{top}px;"
285 style += "width: #{width}px;"
285 style += "width: #{width}px;"
286 style += "height: #{height}px;"
286 style += "height: #{height}px;"
287 style += "font-size:0.7em;"
287 style += "font-size:0.7em;"
288 clss = "gantt_hdr"
288 clss = "gantt_hdr"
289 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
289 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
290 %>
290 %>
291 <%= content_tag(:div, :style => style, :class => clss) do %>
291 <%= content_tag(:div, :style => style, :class => clss) do %>
292 <%= day_letter(wday) %>
292 <%= day_letter(wday) %>
293 <% end %>
293 <% end %>
294 <%
294 <%
295 left = left + width + 1
295 left = left + width + 1
296 wday = wday + 1
296 wday = wday + 1
297 wday = 1 if wday > 7
297 wday = 1 if wday > 7
298 %>
298 %>
299 <% end %>
299 <% end %>
300 <% end %>
300 <% end %>
301
301
302 <%= @gantt.lines.html_safe %>
302 <%= @gantt.lines.html_safe %>
303
303
304 <% ###### Today red line (excluded from cache) ###### %>
304 <% ###### Today red line (excluded from cache) ###### %>
305 <% if User.current.today >= @gantt.date_from and User.current.today <= @gantt.date_to %>
305 <% if User.current.today >= @gantt.date_from and User.current.today <= @gantt.date_to %>
306 <%
306 <%
307 today_left = (((User.current.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
307 today_left = (((User.current.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
308 style = ""
308 style = ""
309 style += "position: absolute;"
309 style += "position: absolute;"
310 style += "height: #{g_height}px;"
310 style += "height: #{g_height}px;"
311 style += "top: #{headers_height + 1}px;"
311 style += "top: #{headers_height + 1}px;"
312 style += "left: #{today_left}px;"
312 style += "left: #{today_left}px;"
313 style += "width:10px;"
313 style += "width:10px;"
314 style += "border-left: 1px dashed red;"
314 style += "border-left: 1px dashed red;"
315 %>
315 %>
316 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :id => 'today_line') %>
316 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :id => 'today_line') %>
317 <% end %>
317 <% end %>
318 <%
318 <%
319 style = ""
319 style = ""
320 style += "position: absolute;"
320 style += "position: absolute;"
321 style += "height: #{g_height}px;"
321 style += "height: #{g_height}px;"
322 style += "top: #{headers_height + 1}px;"
322 style += "top: #{headers_height + 1}px;"
323 style += "left: 0px;"
323 style += "left: 0px;"
324 style += "width: #{g_width - 1}px;"
324 style += "width: #{g_width - 1}px;"
325 %>
325 %>
326 <%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %>
326 <%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %>
327 </div>
327 </div>
328 </td>
328 </td>
329 </tr>
329 </tr>
330 </table>
330 </table>
331
331
332 <table style="width:100%">
332 <table style="width:100%">
333 <tr>
333 <tr>
334 <td style="text-align:left;">
334 <td style="text-align:left;">
335 <%= link_to("\xc2\xab " + l(:label_previous),
335 <%= link_to("\xc2\xab " + l(:label_previous),
336 params.merge(@gantt.params_previous),
336 {:params => request.query_parameters.merge(@gantt.params_previous)},
337 :accesskey => accesskey(:previous)) %>
337 :accesskey => accesskey(:previous)) %>
338 </td>
338 </td>
339 <td style="text-align:right;">
339 <td style="text-align:right;">
340 <%= link_to(l(:label_next) + " \xc2\xbb",
340 <%= link_to(l(:label_next) + " \xc2\xbb",
341 params.merge(@gantt.params_next),
341 {:params => request.query_parameters.merge(@gantt.params_next)},
342 :accesskey => accesskey(:next)) %>
342 :accesskey => accesskey(:next)) %>
343 </td>
343 </td>
344 </tr>
344 </tr>
345 </table>
345 </table>
346
346
347 <% other_formats_links do |f| %>
347 <% other_formats_links do |f| %>
348 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
348 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
349 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
349 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
350 <% end %>
350 <% end %>
351 <% end # query.valid? %>
351 <% end # query.valid? %>
352
352
353 <% content_for :sidebar do %>
353 <% content_for :sidebar do %>
354 <%= render :partial => 'issues/sidebar' %>
354 <%= render :partial => 'issues/sidebar' %>
355 <% end %>
355 <% end %>
356
356
357 <% html_title(l(:label_gantt)) -%>
357 <% html_title(l(:label_gantt)) -%>
358
358
359 <% content_for :header_tags do %>
359 <% content_for :header_tags do %>
360 <%= javascript_include_tag 'raphael' %>
360 <%= javascript_include_tag 'raphael' %>
361 <%= javascript_include_tag 'gantt' %>
361 <%= javascript_include_tag 'gantt' %>
362 <% end %>
362 <% end %>
363
363
364 <%= javascript_tag do %>
364 <%= javascript_tag do %>
365 var issue_relation_type = <%= raw Redmine::Helpers::Gantt::DRAW_TYPES.to_json %>;
365 var issue_relation_type = <%= raw Redmine::Helpers::Gantt::DRAW_TYPES.to_json %>;
366 $(document).ready(drawGanttHandler);
366 $(document).ready(drawGanttHandler);
367 $(window).resize(drawGanttHandler);
367 $(window).resize(drawGanttHandler);
368 $(function() {
368 $(function() {
369 $("#draw_relations").change(drawGanttHandler);
369 $("#draw_relations").change(drawGanttHandler);
370 $("#draw_progress_line").change(drawGanttHandler);
370 $("#draw_progress_line").change(drawGanttHandler);
371 });
371 });
372 <% end %>
372 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now