##// END OF EJS Templates
Some deprecation fixes (end_form_tag and count API)....
Jean-Philippe Lang -
r665:317b460d9652
parent child
Show More
@@ -1,186 +1,186
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module ProjectsHelper
18 module ProjectsHelper
19 def link_to_version(version, options = {})
19 def link_to_version(version, options = {})
20 return '' unless version && version.is_a?(Version)
20 return '' unless version && version.is_a?(Version)
21 link_to version.name, {:controller => 'projects',
21 link_to version.name, {:controller => 'projects',
22 :action => 'roadmap',
22 :action => 'roadmap',
23 :id => version.project_id,
23 :id => version.project_id,
24 :completed => (version.completed? ? 1 : nil),
24 :completed => (version.completed? ? 1 : nil),
25 :anchor => version.name
25 :anchor => version.name
26 }, options
26 }, options
27 end
27 end
28
28
29 # Generates a gantt image
29 # Generates a gantt image
30 # Only defined if RMagick is avalaible
30 # Only defined if RMagick is avalaible
31 def gantt_image(events, date_from, months, zoom)
31 def gantt_image(events, date_from, months, zoom)
32 date_to = (date_from >> months)-1
32 date_to = (date_from >> months)-1
33 show_weeks = zoom > 1
33 show_weeks = zoom > 1
34 show_days = zoom > 2
34 show_days = zoom > 2
35
35
36 subject_width = 320
36 subject_width = 320
37 header_heigth = 18
37 header_heigth = 18
38 # width of one day in pixels
38 # width of one day in pixels
39 zoom = zoom*2
39 zoom = zoom*2
40 g_width = (date_to - date_from + 1)*zoom
40 g_width = (date_to - date_from + 1)*zoom
41 g_height = 20 * events.length + 20
41 g_height = 20 * events.length + 20
42 headers_heigth = (show_weeks ? 2*header_heigth : header_heigth)
42 headers_heigth = (show_weeks ? 2*header_heigth : header_heigth)
43 height = g_height + headers_heigth
43 height = g_height + headers_heigth
44
44
45 imgl = Magick::ImageList.new
45 imgl = Magick::ImageList.new
46 imgl.new_image(subject_width+g_width+1, height)
46 imgl.new_image(subject_width+g_width+1, height)
47 gc = Magick::Draw.new
47 gc = Magick::Draw.new
48
48
49 # Subjects
49 # Subjects
50 top = headers_heigth + 20
50 top = headers_heigth + 20
51 gc.fill('black')
51 gc.fill('black')
52 gc.stroke('transparent')
52 gc.stroke('transparent')
53 gc.stroke_width(1)
53 gc.stroke_width(1)
54 events.each do |i|
54 events.each do |i|
55 gc.text(4, top + 2, (i.is_a?(Issue) ? i.subject : i.name))
55 gc.text(4, top + 2, (i.is_a?(Issue) ? i.subject : i.name))
56 top = top + 20
56 top = top + 20
57 end
57 end
58
58
59 # Months headers
59 # Months headers
60 month_f = date_from
60 month_f = date_from
61 left = subject_width
61 left = subject_width
62 months.times do
62 months.times do
63 width = ((month_f >> 1) - month_f) * zoom
63 width = ((month_f >> 1) - month_f) * zoom
64 gc.fill('white')
64 gc.fill('white')
65 gc.stroke('grey')
65 gc.stroke('grey')
66 gc.stroke_width(1)
66 gc.stroke_width(1)
67 gc.rectangle(left, 0, left + width, height)
67 gc.rectangle(left, 0, left + width, height)
68 gc.fill('black')
68 gc.fill('black')
69 gc.stroke('transparent')
69 gc.stroke('transparent')
70 gc.stroke_width(1)
70 gc.stroke_width(1)
71 gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
71 gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
72 left = left + width
72 left = left + width
73 month_f = month_f >> 1
73 month_f = month_f >> 1
74 end
74 end
75
75
76 # Weeks headers
76 # Weeks headers
77 if show_weeks
77 if show_weeks
78 left = subject_width
78 left = subject_width
79 height = header_heigth
79 height = header_heigth
80 if date_from.cwday == 1
80 if date_from.cwday == 1
81 # date_from is monday
81 # date_from is monday
82 week_f = date_from
82 week_f = date_from
83 else
83 else
84 # find next monday after date_from
84 # find next monday after date_from
85 week_f = date_from + (7 - date_from.cwday + 1)
85 week_f = date_from + (7 - date_from.cwday + 1)
86 width = (7 - date_from.cwday + 1) * zoom
86 width = (7 - date_from.cwday + 1) * zoom
87 gc.fill('white')
87 gc.fill('white')
88 gc.stroke('grey')
88 gc.stroke('grey')
89 gc.stroke_width(1)
89 gc.stroke_width(1)
90 gc.rectangle(left, header_heigth, left + width, 2*header_heigth + g_height-1)
90 gc.rectangle(left, header_heigth, left + width, 2*header_heigth + g_height-1)
91 left = left + width
91 left = left + width
92 end
92 end
93 while week_f <= date_to
93 while week_f <= date_to
94 width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
94 width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
95 gc.fill('white')
95 gc.fill('white')
96 gc.stroke('grey')
96 gc.stroke('grey')
97 gc.stroke_width(1)
97 gc.stroke_width(1)
98 gc.rectangle(left.round, header_heigth, left.round + width, 2*header_heigth + g_height-1)
98 gc.rectangle(left.round, header_heigth, left.round + width, 2*header_heigth + g_height-1)
99 gc.fill('black')
99 gc.fill('black')
100 gc.stroke('transparent')
100 gc.stroke('transparent')
101 gc.stroke_width(1)
101 gc.stroke_width(1)
102 gc.text(left.round + 2, header_heigth + 14, week_f.cweek.to_s)
102 gc.text(left.round + 2, header_heigth + 14, week_f.cweek.to_s)
103 left = left + width
103 left = left + width
104 week_f = week_f+7
104 week_f = week_f+7
105 end
105 end
106 end
106 end
107
107
108 # Days details (week-end in grey)
108 # Days details (week-end in grey)
109 if show_days
109 if show_days
110 left = subject_width
110 left = subject_width
111 height = g_height + header_heigth - 1
111 height = g_height + header_heigth - 1
112 wday = date_from.cwday
112 wday = date_from.cwday
113 (date_to - date_from + 1).to_i.times do
113 (date_to - date_from + 1).to_i.times do
114 width = zoom
114 width = zoom
115 gc.fill(wday == 6 || wday == 7 ? '#eee' : 'white')
115 gc.fill(wday == 6 || wday == 7 ? '#eee' : 'white')
116 gc.stroke('grey')
116 gc.stroke('grey')
117 gc.stroke_width(1)
117 gc.stroke_width(1)
118 gc.rectangle(left, 2*header_heigth, left + width, 2*header_heigth + g_height-1)
118 gc.rectangle(left, 2*header_heigth, left + width, 2*header_heigth + g_height-1)
119 left = left + width
119 left = left + width
120 wday = wday + 1
120 wday = wday + 1
121 wday = 1 if wday > 7
121 wday = 1 if wday > 7
122 end
122 end
123 end
123 end
124
124
125 # border
125 # border
126 gc.fill('transparent')
126 gc.fill('transparent')
127 gc.stroke('grey')
127 gc.stroke('grey')
128 gc.stroke_width(1)
128 gc.stroke_width(1)
129 gc.rectangle(0, 0, subject_width+g_width, headers_heigth)
129 gc.rectangle(0, 0, subject_width+g_width, headers_heigth)
130 gc.stroke('black')
130 gc.stroke('black')
131 gc.rectangle(0, 0, subject_width+g_width, g_height+ headers_heigth-1)
131 gc.rectangle(0, 0, subject_width+g_width, g_height+ headers_heigth-1)
132
132
133 # content
133 # content
134 top = headers_heigth + 20
134 top = headers_heigth + 20
135 gc.stroke('transparent')
135 gc.stroke('transparent')
136 events.each do |i|
136 events.each do |i|
137 if i.is_a?(Issue)
137 if i.is_a?(Issue)
138 i_start_date = (i.start_date >= date_from ? i.start_date : date_from )
138 i_start_date = (i.start_date >= date_from ? i.start_date : date_from )
139 i_end_date = (i.due_date <= date_to ? i.due_date : date_to )
139 i_end_date = (i.due_date <= date_to ? i.due_date : date_to )
140 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
140 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
141 i_done_date = (i_done_date <= date_from ? date_from : i_done_date )
141 i_done_date = (i_done_date <= date_from ? date_from : i_done_date )
142 i_done_date = (i_done_date >= date_to ? date_to : i_done_date )
142 i_done_date = (i_done_date >= date_to ? date_to : i_done_date )
143 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
143 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
144
144
145 i_left = subject_width + ((i_start_date - date_from)*zoom).floor
145 i_left = subject_width + ((i_start_date - date_from)*zoom).floor
146 i_width = ((i_end_date - i_start_date + 1)*zoom).floor # total width of the issue
146 i_width = ((i_end_date - i_start_date + 1)*zoom).floor # total width of the issue
147 d_width = ((i_done_date - i_start_date)*zoom).floor # done width
147 d_width = ((i_done_date - i_start_date)*zoom).floor # done width
148 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor : 0 # delay width
148 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor : 0 # delay width
149
149
150 gc.fill('grey')
150 gc.fill('grey')
151 gc.rectangle(i_left, top, i_left + i_width, top - 6)
151 gc.rectangle(i_left, top, i_left + i_width, top - 6)
152 gc.fill('red')
152 gc.fill('red')
153 gc.rectangle(i_left, top, i_left + l_width, top - 6) if l_width > 0
153 gc.rectangle(i_left, top, i_left + l_width, top - 6) if l_width > 0
154 gc.fill('blue')
154 gc.fill('blue')
155 gc.rectangle(i_left, top, i_left + d_width, top - 6) if d_width > 0
155 gc.rectangle(i_left, top, i_left + d_width, top - 6) if d_width > 0
156 gc.fill('black')
156 gc.fill('black')
157 gc.text(i_left + i_width + 5,top + 1, "#{i.status.name} #{i.done_ratio}%")
157 gc.text(i_left + i_width + 5,top + 1, "#{i.status.name} #{i.done_ratio}%")
158 else
158 else
159 i_left = subject_width + ((i.start_date - date_from)*zoom).floor
159 i_left = subject_width + ((i.start_date - date_from)*zoom).floor
160 gc.fill('green')
160 gc.fill('green')
161 gc.rectangle(i_left, top, i_left + 6, top - 6)
161 gc.rectangle(i_left, top, i_left + 6, top - 6)
162 gc.fill('black')
162 gc.fill('black')
163 gc.text(i_left + 11, top + 1, i.name)
163 gc.text(i_left + 11, top + 1, i.name)
164 end
164 end
165 top = top + 20
165 top = top + 20
166 end
166 end
167
167
168 # today red line
168 # today red line
169 if Date.today >= @date_from and Date.today <= @date_to
169 if Date.today >= @date_from and Date.today <= @date_to
170 gc.stroke('red')
170 gc.stroke('red')
171 x = (Date.today-@date_from+1)*zoom + subject_width
171 x = (Date.today-@date_from+1)*zoom + subject_width
172 gc.line(x, headers_heigth, x, headers_heigth + g_height-1)
172 gc.line(x, headers_heigth, x, headers_heigth + g_height-1)
173 end
173 end
174
174
175 gc.draw(imgl)
175 gc.draw(imgl)
176 imgl
176 imgl
177 end if Object.const_defined?(:Magick)
177 end if Object.const_defined?(:Magick)
178
178
179 def new_issue_selector
179 def new_issue_selector
180 trackers = Tracker.find(:all, :order => 'position')
180 trackers = Tracker.find(:all, :order => 'position')
181 form_tag({:controller => 'projects', :action => 'add_issue', :id => @project}, :method => :get) +
181 # can't use form tag inside helper
182 select_tag('tracker_id', '<option></option' + options_from_collection_for_select(trackers, 'id', 'name'),
182 content_tag('form',
183 :onchange => "if (this.value != '') {this.form.submit()}") +
183 select_tag('tracker_id', '<option></option' + options_from_collection_for_select(trackers, 'id', 'name'), :onchange => "if (this.value != '') {this.form.submit()}"),
184 end_form_tag
184 :action => url_for(:controller => 'projects', :action => 'add_issue', :id => @project), :method => 'get')
185 end
185 end
186 end
186 end
@@ -1,28 +1,28
1 <h2><%=h @user.name %></h2>
1 <h2><%=h @user.name %></h2>
2
2
3 <p>
3 <p>
4 <%= mail_to @user.mail unless @user.pref.hide_mail %>
4 <%= mail_to @user.mail unless @user.pref.hide_mail %>
5 <ul>
5 <ul>
6 <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
6 <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
7 <% for custom_value in @custom_values %>
7 <% for custom_value in @custom_values %>
8 <% if !custom_value.value.empty? %>
8 <% if !custom_value.value.empty? %>
9 <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
9 <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
10 <% end %>
10 <% end %>
11 <% end %>
11 <% end %>
12 </ul>
12 </ul>
13 </p>
13 </p>
14
14
15 <% unless @memberships.empty? %>
15 <% unless @memberships.empty? %>
16 <h3><%=l(:label_project_plural)%></h3>
16 <h3><%=l(:label_project_plural)%></h3>
17 <ul>
17 <ul>
18 <% for membership in @memberships %>
18 <% for membership in @memberships %>
19 <li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %>
19 <li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %>
20 (<%= membership.role.name %>, <%= format_date(membership.created_on) %>)</li>
20 (<%= membership.role.name %>, <%= format_date(membership.created_on) %>)</li>
21 <% end %>
21 <% end %>
22 </ul>
22 </ul>
23 <% end %>
23 <% end %>
24
24
25 <h3><%=l(:label_activity)%></h3>
25 <h3><%=l(:label_activity)%></h3>
26 <p>
26 <p>
27 <%=l(:label_reported_issues)%>: <%= Issue.count(["author_id=?", @user.id]) %>
27 <%=l(:label_reported_issues)%>: <%= Issue.count(:conditions => ["author_id=?", @user.id]) %>
28 </p> No newline at end of file
28 </p>
@@ -1,31 +1,31
1 <h2><%=l(:label_permissions_report)%></h2>
1 <h2><%=l(:label_permissions_report)%></h2>
2
2
3 <%= start_form_tag({:action => 'report'}, :id => 'permissions_form') %>
3 <% form_tag({:action => 'report'}, :id => 'permissions_form') do %>
4 <%= hidden_field_tag 'permissions[0]', '' %>
4 <%= hidden_field_tag 'permissions[0]', '' %>
5 <table class="list">
5 <table class="list">
6 <thead>
6 <thead>
7 <tr>
7 <tr>
8 <th><%=l(:label_permissions)%></th>
8 <th><%=l(:label_permissions)%></th>
9 <% @roles.each do |role| %>
9 <% @roles.each do |role| %>
10 <th><%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %></th>
10 <th><%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %></th>
11 <% end %>
11 <% end %>
12 </tr>
12 </tr>
13 </thead>
13 </thead>
14 <tbody>
14 <tbody>
15 <% @permissions.each do |permission| %>
15 <% @permissions.each do |permission| %>
16 <tr class="<%= cycle('odd', 'even') %>">
16 <tr class="<%= cycle('odd', 'even') %>">
17 <td><%= permission.name.to_s.humanize %></td>
17 <td><%= permission.name.to_s.humanize %></td>
18 <% @roles.each do |role| %>
18 <% @roles.each do |role| %>
19 <td align="center">
19 <td align="center">
20 <% if role.setable_permissions.include? permission %>
20 <% if role.setable_permissions.include? permission %>
21 <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name) %>
21 <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name) %>
22 <% end %>
22 <% end %>
23 </td>
23 </td>
24 <% end %>
24 <% end %>
25 </tr>
25 </tr>
26 <% end %>
26 <% end %>
27 </tbody>
27 </tbody>
28 </table>
28 </table>
29 <p><%= check_all_links 'permissions_form' %></p>
29 <p><%= check_all_links 'permissions_form' %></p>
30 <p><%= submit_tag l(:button_save) %></p>
30 <p><%= submit_tag l(:button_save) %></p>
31 <%= end_form_tag %>
31 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now