##// 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 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 ProjectsHelper
19 19 def link_to_version(version, options = {})
20 20 return '' unless version && version.is_a?(Version)
21 21 link_to version.name, {:controller => 'projects',
22 22 :action => 'roadmap',
23 23 :id => version.project_id,
24 24 :completed => (version.completed? ? 1 : nil),
25 25 :anchor => version.name
26 26 }, options
27 27 end
28 28
29 29 # Generates a gantt image
30 30 # Only defined if RMagick is avalaible
31 31 def gantt_image(events, date_from, months, zoom)
32 32 date_to = (date_from >> months)-1
33 33 show_weeks = zoom > 1
34 34 show_days = zoom > 2
35 35
36 36 subject_width = 320
37 37 header_heigth = 18
38 38 # width of one day in pixels
39 39 zoom = zoom*2
40 40 g_width = (date_to - date_from + 1)*zoom
41 41 g_height = 20 * events.length + 20
42 42 headers_heigth = (show_weeks ? 2*header_heigth : header_heigth)
43 43 height = g_height + headers_heigth
44 44
45 45 imgl = Magick::ImageList.new
46 46 imgl.new_image(subject_width+g_width+1, height)
47 47 gc = Magick::Draw.new
48 48
49 49 # Subjects
50 50 top = headers_heigth + 20
51 51 gc.fill('black')
52 52 gc.stroke('transparent')
53 53 gc.stroke_width(1)
54 54 events.each do |i|
55 55 gc.text(4, top + 2, (i.is_a?(Issue) ? i.subject : i.name))
56 56 top = top + 20
57 57 end
58 58
59 59 # Months headers
60 60 month_f = date_from
61 61 left = subject_width
62 62 months.times do
63 63 width = ((month_f >> 1) - month_f) * zoom
64 64 gc.fill('white')
65 65 gc.stroke('grey')
66 66 gc.stroke_width(1)
67 67 gc.rectangle(left, 0, left + width, height)
68 68 gc.fill('black')
69 69 gc.stroke('transparent')
70 70 gc.stroke_width(1)
71 71 gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
72 72 left = left + width
73 73 month_f = month_f >> 1
74 74 end
75 75
76 76 # Weeks headers
77 77 if show_weeks
78 78 left = subject_width
79 79 height = header_heigth
80 80 if date_from.cwday == 1
81 81 # date_from is monday
82 82 week_f = date_from
83 83 else
84 84 # find next monday after date_from
85 85 week_f = date_from + (7 - date_from.cwday + 1)
86 86 width = (7 - date_from.cwday + 1) * zoom
87 87 gc.fill('white')
88 88 gc.stroke('grey')
89 89 gc.stroke_width(1)
90 90 gc.rectangle(left, header_heigth, left + width, 2*header_heigth + g_height-1)
91 91 left = left + width
92 92 end
93 93 while week_f <= date_to
94 94 width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
95 95 gc.fill('white')
96 96 gc.stroke('grey')
97 97 gc.stroke_width(1)
98 98 gc.rectangle(left.round, header_heigth, left.round + width, 2*header_heigth + g_height-1)
99 99 gc.fill('black')
100 100 gc.stroke('transparent')
101 101 gc.stroke_width(1)
102 102 gc.text(left.round + 2, header_heigth + 14, week_f.cweek.to_s)
103 103 left = left + width
104 104 week_f = week_f+7
105 105 end
106 106 end
107 107
108 108 # Days details (week-end in grey)
109 109 if show_days
110 110 left = subject_width
111 111 height = g_height + header_heigth - 1
112 112 wday = date_from.cwday
113 113 (date_to - date_from + 1).to_i.times do
114 114 width = zoom
115 115 gc.fill(wday == 6 || wday == 7 ? '#eee' : 'white')
116 116 gc.stroke('grey')
117 117 gc.stroke_width(1)
118 118 gc.rectangle(left, 2*header_heigth, left + width, 2*header_heigth + g_height-1)
119 119 left = left + width
120 120 wday = wday + 1
121 121 wday = 1 if wday > 7
122 122 end
123 123 end
124 124
125 125 # border
126 126 gc.fill('transparent')
127 127 gc.stroke('grey')
128 128 gc.stroke_width(1)
129 129 gc.rectangle(0, 0, subject_width+g_width, headers_heigth)
130 130 gc.stroke('black')
131 131 gc.rectangle(0, 0, subject_width+g_width, g_height+ headers_heigth-1)
132 132
133 133 # content
134 134 top = headers_heigth + 20
135 135 gc.stroke('transparent')
136 136 events.each do |i|
137 137 if i.is_a?(Issue)
138 138 i_start_date = (i.start_date >= date_from ? i.start_date : date_from )
139 139 i_end_date = (i.due_date <= date_to ? i.due_date : date_to )
140 140 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
141 141 i_done_date = (i_done_date <= date_from ? date_from : i_done_date )
142 142 i_done_date = (i_done_date >= date_to ? date_to : i_done_date )
143 143 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
144 144
145 145 i_left = subject_width + ((i_start_date - date_from)*zoom).floor
146 146 i_width = ((i_end_date - i_start_date + 1)*zoom).floor # total width of the issue
147 147 d_width = ((i_done_date - i_start_date)*zoom).floor # done width
148 148 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor : 0 # delay width
149 149
150 150 gc.fill('grey')
151 151 gc.rectangle(i_left, top, i_left + i_width, top - 6)
152 152 gc.fill('red')
153 153 gc.rectangle(i_left, top, i_left + l_width, top - 6) if l_width > 0
154 154 gc.fill('blue')
155 155 gc.rectangle(i_left, top, i_left + d_width, top - 6) if d_width > 0
156 156 gc.fill('black')
157 157 gc.text(i_left + i_width + 5,top + 1, "#{i.status.name} #{i.done_ratio}%")
158 158 else
159 159 i_left = subject_width + ((i.start_date - date_from)*zoom).floor
160 160 gc.fill('green')
161 161 gc.rectangle(i_left, top, i_left + 6, top - 6)
162 162 gc.fill('black')
163 163 gc.text(i_left + 11, top + 1, i.name)
164 164 end
165 165 top = top + 20
166 166 end
167 167
168 168 # today red line
169 169 if Date.today >= @date_from and Date.today <= @date_to
170 170 gc.stroke('red')
171 171 x = (Date.today-@date_from+1)*zoom + subject_width
172 172 gc.line(x, headers_heigth, x, headers_heigth + g_height-1)
173 173 end
174 174
175 175 gc.draw(imgl)
176 176 imgl
177 177 end if Object.const_defined?(:Magick)
178 178
179 179 def new_issue_selector
180 180 trackers = Tracker.find(:all, :order => 'position')
181 form_tag({:controller => 'projects', :action => 'add_issue', :id => @project}, :method => :get) +
182 select_tag('tracker_id', '<option></option' + options_from_collection_for_select(trackers, 'id', 'name'),
183 :onchange => "if (this.value != '') {this.form.submit()}") +
184 end_form_tag
181 # can't use form tag inside helper
182 content_tag('form',
183 select_tag('tracker_id', '<option></option' + options_from_collection_for_select(trackers, 'id', 'name'), :onchange => "if (this.value != '') {this.form.submit()}"),
184 :action => url_for(:controller => 'projects', :action => 'add_issue', :id => @project), :method => 'get')
185 185 end
186 186 end
@@ -1,28 +1,28
1 1 <h2><%=h @user.name %></h2>
2 2
3 3 <p>
4 4 <%= mail_to @user.mail unless @user.pref.hide_mail %>
5 5 <ul>
6 6 <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
7 7 <% for custom_value in @custom_values %>
8 8 <% if !custom_value.value.empty? %>
9 9 <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
10 10 <% end %>
11 11 <% end %>
12 12 </ul>
13 13 </p>
14 14
15 15 <% unless @memberships.empty? %>
16 16 <h3><%=l(:label_project_plural)%></h3>
17 17 <ul>
18 18 <% for membership in @memberships %>
19 19 <li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %>
20 20 (<%= membership.role.name %>, <%= format_date(membership.created_on) %>)</li>
21 21 <% end %>
22 22 </ul>
23 23 <% end %>
24 24
25 25 <h3><%=l(:label_activity)%></h3>
26 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 28 </p> No newline at end of file
@@ -1,31 +1,31
1 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 4 <%= hidden_field_tag 'permissions[0]', '' %>
5 5 <table class="list">
6 6 <thead>
7 7 <tr>
8 8 <th><%=l(:label_permissions)%></th>
9 9 <% @roles.each do |role| %>
10 10 <th><%= content_tag(role.builtin? ? 'em' : 'span', h(role.name)) %></th>
11 11 <% end %>
12 12 </tr>
13 13 </thead>
14 14 <tbody>
15 15 <% @permissions.each do |permission| %>
16 16 <tr class="<%= cycle('odd', 'even') %>">
17 17 <td><%= permission.name.to_s.humanize %></td>
18 18 <% @roles.each do |role| %>
19 19 <td align="center">
20 20 <% if role.setable_permissions.include? permission %>
21 21 <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name) %>
22 22 <% end %>
23 23 </td>
24 24 <% end %>
25 25 </tr>
26 26 <% end %>
27 27 </tbody>
28 28 </table>
29 29 <p><%= check_all_links 'permissions_form' %></p>
30 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