|
1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
module ProjectsHelper
|
|
19
|
def link_to_version(version, options = {})
|
|
20
|
return '' unless version && version.is_a?(Version)
|
|
21
|
link_to version.name, {:controller => 'projects',
|
|
22
|
:action => 'roadmap',
|
|
23
|
:id => version.project_id,
|
|
24
|
:completed => (version.completed? ? 1 : nil),
|
|
25
|
:anchor => version.name
|
|
26
|
}, options
|
|
27
|
end
|
|
28
|
|
|
29
|
def project_settings_tabs
|
|
30
|
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
|
31
|
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
|
32
|
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
|
|
33
|
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
|
34
|
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
|
35
|
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
|
36
|
{:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository},
|
|
37
|
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}
|
|
38
|
]
|
|
39
|
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
|
40
|
end
|
|
41
|
|
|
42
|
|
|
43
|
|
|
44
|
def gantt_image(events, date_from, months, zoom)
|
|
45
|
date_to = (date_from >> months)-1
|
|
46
|
show_weeks = zoom > 1
|
|
47
|
show_days = zoom > 2
|
|
48
|
|
|
49
|
subject_width = 320
|
|
50
|
header_heigth = 18
|
|
51
|
|
|
52
|
zoom = zoom*2
|
|
53
|
g_width = (date_to - date_from + 1)*zoom
|
|
54
|
g_height = 20 * events.length + 20
|
|
55
|
headers_heigth = (show_weeks ? 2*header_heigth : header_heigth)
|
|
56
|
height = g_height + headers_heigth
|
|
57
|
|
|
58
|
imgl = Magick::ImageList.new
|
|
59
|
imgl.new_image(subject_width+g_width+1, height)
|
|
60
|
gc = Magick::Draw.new
|
|
61
|
|
|
62
|
|
|
63
|
top = headers_heigth + 20
|
|
64
|
gc.fill('black')
|
|
65
|
gc.stroke('transparent')
|
|
66
|
gc.stroke_width(1)
|
|
67
|
events.each do |i|
|
|
68
|
gc.text(4, top + 2, (i.is_a?(Issue) ? i.subject : i.name))
|
|
69
|
top = top + 20
|
|
70
|
end
|
|
71
|
|
|
72
|
|
|
73
|
month_f = date_from
|
|
74
|
left = subject_width
|
|
75
|
months.times do
|
|
76
|
width = ((month_f >> 1) - month_f) * zoom
|
|
77
|
gc.fill('white')
|
|
78
|
gc.stroke('grey')
|
|
79
|
gc.stroke_width(1)
|
|
80
|
gc.rectangle(left, 0, left + width, height)
|
|
81
|
gc.fill('black')
|
|
82
|
gc.stroke('transparent')
|
|
83
|
gc.stroke_width(1)
|
|
84
|
gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
|
|
85
|
left = left + width
|
|
86
|
month_f = month_f >> 1
|
|
87
|
end
|
|
88
|
|
|
89
|
|
|
90
|
if show_weeks
|
|
91
|
left = subject_width
|
|
92
|
height = header_heigth
|
|
93
|
if date_from.cwday == 1
|
|
94
|
|
|
95
|
week_f = date_from
|
|
96
|
else
|
|
97
|
|
|
98
|
week_f = date_from + (7 - date_from.cwday + 1)
|
|
99
|
width = (7 - date_from.cwday + 1) * zoom
|
|
100
|
gc.fill('white')
|
|
101
|
gc.stroke('grey')
|
|
102
|
gc.stroke_width(1)
|
|
103
|
gc.rectangle(left, header_heigth, left + width, 2*header_heigth + g_height-1)
|
|
104
|
left = left + width
|
|
105
|
end
|
|
106
|
while week_f <= date_to
|
|
107
|
width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
|
|
108
|
gc.fill('white')
|
|
109
|
gc.stroke('grey')
|
|
110
|
gc.stroke_width(1)
|
|
111
|
gc.rectangle(left.round, header_heigth, left.round + width, 2*header_heigth + g_height-1)
|
|
112
|
gc.fill('black')
|
|
113
|
gc.stroke('transparent')
|
|
114
|
gc.stroke_width(1)
|
|
115
|
gc.text(left.round + 2, header_heigth + 14, week_f.cweek.to_s)
|
|
116
|
left = left + width
|
|
117
|
week_f = week_f+7
|
|
118
|
end
|
|
119
|
end
|
|
120
|
|
|
121
|
|
|
122
|
if show_days
|
|
123
|
left = subject_width
|
|
124
|
height = g_height + header_heigth - 1
|
|
125
|
wday = date_from.cwday
|
|
126
|
(date_to - date_from + 1).to_i.times do
|
|
127
|
width = zoom
|
|
128
|
gc.fill(wday == 6 || wday == 7 ? '#eee' : 'white')
|
|
129
|
gc.stroke('grey')
|
|
130
|
gc.stroke_width(1)
|
|
131
|
gc.rectangle(left, 2*header_heigth, left + width, 2*header_heigth + g_height-1)
|
|
132
|
left = left + width
|
|
133
|
wday = wday + 1
|
|
134
|
wday = 1 if wday > 7
|
|
135
|
end
|
|
136
|
end
|
|
137
|
|
|
138
|
|
|
139
|
gc.fill('transparent')
|
|
140
|
gc.stroke('grey')
|
|
141
|
gc.stroke_width(1)
|
|
142
|
gc.rectangle(0, 0, subject_width+g_width, headers_heigth)
|
|
143
|
gc.stroke('black')
|
|
144
|
gc.rectangle(0, 0, subject_width+g_width, g_height+ headers_heigth-1)
|
|
145
|
|
|
146
|
|
|
147
|
top = headers_heigth + 20
|
|
148
|
gc.stroke('transparent')
|
|
149
|
events.each do |i|
|
|
150
|
if i.is_a?(Issue)
|
|
151
|
i_start_date = (i.total('start_date') >= date_from ? i.total('start_date') : date_from )
|
|
152
|
i_end_date = (i.total('due_date') <= date_to ? i.total('due_date') : date_to )
|
|
153
|
|
|
154
|
i_done_date = i.total('start_date') + i.total('actual_days')
|
|
155
|
i_done_date = (i_done_date <= date_from ? date_from : i_done_date )
|
|
156
|
i_done_date = (i_done_date >= date_to ? date_to : i_done_date )
|
|
157
|
i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
|
|
158
|
|
|
159
|
i_left = subject_width + ((i_start_date - date_from)*zoom).floor
|
|
160
|
i_width = ((i_end_date - i_start_date + 1)*zoom).floor
|
|
161
|
d_width = ((i_done_date - i_start_date)*zoom).floor
|
|
162
|
l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor : 0
|
|
163
|
|
|
164
|
gc.fill('grey')
|
|
165
|
gc.rectangle(i_left, top, i_left + i_width, top - 6)
|
|
166
|
gc.fill('red')
|
|
167
|
gc.rectangle(i_left, top, i_left + l_width, top - 6) if l_width > 0
|
|
168
|
gc.fill('blue')
|
|
169
|
gc.rectangle(i_left, top, i_left + d_width, top - 6) if d_width > 0
|
|
170
|
gc.fill('black')
|
|
171
|
gc.text(i_left + i_width + 5,top + 1, "#{i.total('status').name} #{i.total('done_ratio')}%")
|
|
172
|
else
|
|
173
|
i_left = subject_width + ((i.start_date - date_from)*zoom).floor
|
|
174
|
gc.fill('green')
|
|
175
|
gc.rectangle(i_left, top, i_left + 6, top - 6)
|
|
176
|
gc.fill('black')
|
|
177
|
gc.text(i_left + 11, top + 1, i.name)
|
|
178
|
end
|
|
179
|
top = top + 20
|
|
180
|
end
|
|
181
|
|
|
182
|
|
|
183
|
if Date.today >= date_from and Date.today <= date_to
|
|
184
|
gc.stroke('red')
|
|
185
|
x = (Date.today-date_from+1)*zoom + subject_width
|
|
186
|
gc.line(x, headers_heigth, x, headers_heigth + g_height-1)
|
|
187
|
end
|
|
188
|
|
|
189
|
gc.draw(imgl)
|
|
190
|
imgl
|
|
191
|
end if Object.const_defined?(:Magick)
|
|
192
|
|
|
193
|
def new_issue_selector
|
|
194
|
trackers = @project.trackers
|
|
195
|
|
|
196
|
content_tag('form',
|
|
197
|
select_tag('tracker_id', '<option></option>' + options_from_collection_for_select(trackers, 'id', 'name'), :onchange => "if (this.value != '') {this.form.submit()}"),
|
|
198
|
:action => url_for(:controller => 'projects', :action => 'add_issue', :id => @project), :method => 'get')
|
|
199
|
end
|
|
200
|
end
|