46 |
46 |
<% zoom = 1
|
47 |
47 |
@gantt.zoom.times { zoom = zoom * 2 }
|
48 |
48 |
|
49 |
|
subject_width = 330
|
|
49 |
subject_width = 280
|
50 |
50 |
header_heigth = 18
|
51 |
51 |
|
52 |
52 |
headers_height = header_heigth
|
... | ... | |
66 |
66 |
g_height = [(20 * @gantt.events.length + 6)+150, 206].max
|
67 |
67 |
t_height = g_height + headers_height
|
68 |
68 |
%>
|
|
69 |
<input type="hidden" name="_date_from" id="i_date_from" value="<%=h(@gantt.date_from)%>" />
|
|
70 |
<input type="hidden" name="_date_to" id="i_date_to" value="<%=h(@gantt.date_to)%>" />
|
|
71 |
<input type="hidden" name="zm" id="i_zm" value="<%=h(zoom)%>" />
|
|
72 |
<script type='text/javascript'>
|
|
73 |
function issue_moved(elem) {
|
|
74 |
var id_str = elem.id.substring(3, elem.id.length);
|
|
75 |
var v_date_from = document.getElementById('i_date_from').getAttribute("value");
|
|
76 |
var v_date_to = document.getElementById('i_date_to').getAttribute("value");
|
|
77 |
var v_zm = document.getElementById('i_zm').getAttribute("value");
|
|
78 |
var url_str = '/issues/edit_gantt/' + id_str;
|
|
79 |
var day = parseInt(elem.style.left)/parseInt(v_zm);
|
|
80 |
new Ajax.Request(url_str, {asynchronous:true, evalScripts:true,
|
|
81 |
parameters: 'day='+day+'&date_from='+v_date_from+'&date_to='+v_date_to+'&zoom='+v_zm,
|
|
82 |
onSuccess:function(obj) {
|
|
83 |
change_dates(obj.responseText);
|
|
84 |
},
|
|
85 |
onFailure:function(obj) {
|
|
86 |
handle_failure(obj.responseText);
|
|
87 |
}
|
|
88 |
});
|
69 |
89 |
|
|
90 |
}
|
|
91 |
|
|
92 |
function handle_failure(res_text) {
|
|
93 |
var text = res_text.split('|');
|
|
94 |
alert(text[0]);
|
|
95 |
if (text.length == 1) {
|
|
96 |
return;
|
|
97 |
}
|
|
98 |
change_dates(text[1]);//revert
|
|
99 |
}
|
|
100 |
|
|
101 |
function change_dates(issue_infos) {
|
|
102 |
if (!issue_infos) {
|
|
103 |
return;
|
|
104 |
}
|
|
105 |
var issue_list = issue_infos.split("|");
|
|
106 |
for (i = 0; i < issue_list.length; i++) {
|
|
107 |
change_date(issue_list[i]);
|
|
108 |
}
|
|
109 |
}
|
|
110 |
|
|
111 |
function change_date(text) {
|
|
112 |
if (!text) {
|
|
113 |
return;
|
|
114 |
}
|
|
115 |
var issue_info = text.split("=");
|
|
116 |
var elem_id = issue_info[0];
|
|
117 |
var vals = issue_info[1].split(',');
|
|
118 |
var start_date_elem = document.getElementById(elem_id + '_start_date_str');
|
|
119 |
if (!start_date_elem) {
|
|
120 |
//target not exists
|
|
121 |
return;
|
|
122 |
}
|
|
123 |
start_date_elem.innerHTML = vals[0];
|
|
124 |
var tooltip_start_date_elem = document.getElementById('tooltip_start_date_' + elem_id);
|
|
125 |
tooltip_start_date_elem.innerHTML = vals[0];
|
|
126 |
var due_date_elem = document.getElementById(elem_id + '_due_date_str');
|
|
127 |
due_date_elem.innerHTML = vals[2];
|
|
128 |
var tooltip_due_date_elem = document.getElementById('tooltip_due_date_' + elem_id);
|
|
129 |
tooltip_due_date_elem.innerHTML = vals[2];
|
|
130 |
|
|
131 |
var ev_elem = document.getElementById('ev_' + elem_id);
|
|
132 |
ev_elem.style.left = vals[4] + 'px';
|
|
133 |
ev_elem.style.width = (parseInt(vals[5])+100)+'px';
|
|
134 |
var todo_elem = document.getElementById('task_todo_' + elem_id);
|
|
135 |
todo_elem.style.width = vals[5] + 'px';
|
|
136 |
var late_elem = document.getElementById('task_late_' + elem_id);
|
|
137 |
if (late_elem) {
|
|
138 |
late_elem.style.width = vals[6] + 'px';
|
|
139 |
if (vals[6] == '0') {
|
|
140 |
late_elem.className = 'task task_none';
|
|
141 |
} else {
|
|
142 |
late_elem.className = 'task task_late';
|
|
143 |
}
|
|
144 |
}
|
|
145 |
var done_elem = document.getElementById('task_done_' + elem_id);
|
|
146 |
if (done_elem) {
|
|
147 |
done_elem.style.width = vals[7] + 'px';
|
|
148 |
if (vals[7] == '0') {
|
|
149 |
done_elem.className = 'task task_none';
|
|
150 |
} else {
|
|
151 |
done_elem.className = 'task task_done';
|
|
152 |
}
|
|
153 |
}
|
|
154 |
var task_elem = document.getElementById('task_task_' + elem_id);
|
|
155 |
if (task_elem) {
|
|
156 |
task_elem.style.left = (parseInt(vals[5])+5) + 'px';
|
|
157 |
}
|
|
158 |
var tooltip = document.getElementById("tt_" + elem_id);
|
|
159 |
tooltip.style.left = ev_elem.style.left;
|
|
160 |
|
|
161 |
//change calendar date
|
|
162 |
document.getElementById(elem_id+"_hidden_start_date").value = vals[1];
|
|
163 |
document.getElementById(elem_id+"_start_date").value = vals[1];
|
|
164 |
document.getElementById(elem_id+"_hidden_due_date").value = vals[3];
|
|
165 |
document.getElementById(elem_id+"_due_date").value = vals[3];
|
|
166 |
}
|
|
167 |
</script>
|
|
168 |
|
70 |
169 |
<table width="100%" style="border:0; border-collapse: collapse;">
|
71 |
170 |
<tr>
|
72 |
171 |
<td style="width:<%= subject_width %>px; padding:0px;">
|
... | ... | |
80 |
179 |
#
|
81 |
180 |
top = headers_height + 8
|
82 |
181 |
@gantt.events.each do |i| %>
|
83 |
|
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
|
|
182 |
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
|
84 |
183 |
<% if i.is_a? Issue %>
|
85 |
184 |
<%= h("#{i.project} -") unless @project && @project == i.project %>
|
86 |
185 |
<%= link_to_issue i %>
|
... | ... | |
88 |
187 |
<span class="icon icon-package">
|
89 |
188 |
<%= link_to_version i %>
|
90 |
189 |
</span>
|
91 |
|
<% end %>
|
|
190 |
<% end %>
|
92 |
191 |
</small></div>
|
93 |
192 |
<% top = top + 20
|
94 |
193 |
end %>
|
95 |
194 |
</div>
|
96 |
195 |
</td>
|
|
196 |
<td style="width:225px; padding:0px;">
|
|
197 |
<div style="position:relative;height:<%= t_height + 24 %>px;width:225px;">
|
|
198 |
<div style="width:225px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
|
|
199 |
<div style="width:225px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
|
|
200 |
<%
|
|
201 |
top = headers_height + 8
|
|
202 |
@gantt.events.each do |i| %>
|
|
203 |
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;"><small>
|
|
204 |
<% if i.is_a? Issue %>
|
|
205 |
<span id="<%=i.id%>_start_date_str" style="font-size: 7pt;"><%= format_date(i.start_date) %></span>
|
|
206 |
<input type="hidden" size="12" id="<%=i.id%>_hidden_start_date" value="<%= i.start_date %>">
|
|
207 |
<input type="hidden" size="12" id="<%=i.id%>_start_date" value="<%= i.start_date %>"><%= calendar_for("#{i.id}_start_date") if i.is_a? Issue %>
|
|
208 |
<script type="text/javascript">
|
|
209 |
//<![CDATA[
|
|
210 |
new Form.Element.Observer('<%=i.id%>_start_date', 0.25,
|
|
211 |
function(element, value) {
|
|
212 |
if (value == document.getElementById('<%=i.id%>_hidden_start_date').value) {
|
|
213 |
return ;
|
|
214 |
}
|
|
215 |
new Ajax.Request('<%=url_for(:controller=>:issues, :action => :edit_gantt, :id=>i.id, :date_from=>@gantt.date_from.strftime("%Y-%m-%d"), :date_to=>@gantt.date_to.strftime("%Y-%m-%d"), :zoom=>zoom, :escape => false) %>', {asynchronous:true, evalScripts:true, onFailure:function(request){handle_failure(request.responseText)}, onSuccess:function(request){change_dates(request.responseText)}, parameters:'start_date=' + encodeURIComponent(value)});
|
|
216 |
})
|
|
217 |
//]]>
|
|
218 |
</script>
|
|
219 |
<span id="<%=i.id%>_due_date_str" style="font-size: 7pt;<%= "color: blue;" unless i.due_date%>">
|
|
220 |
<%= format_date(i.due_before) %>
|
|
221 |
</span>
|
|
222 |
<input type="hidden" size="12" id="<%=i.id%>_hidden_due_date" value="<%= i.due_date %>">
|
|
223 |
<input type="hidden" size="12" id="<%=i.id%>_due_date" value="<%= i.due_date %>"><%= calendar_for("#{i.id}_due_date") if i.due_date%>
|
|
224 |
<script type="text/javascript">
|
|
225 |
//<![CDATA[
|
|
226 |
new Form.Element.Observer('<%=i.id%>_due_date', 0.25,
|
|
227 |
function(element, value) {
|
|
228 |
if (value == document.getElementById('<%=i.id%>_hidden_due_date').value) {
|
|
229 |
return ;
|
|
230 |
}
|
|
231 |
new Ajax.Request('<%=url_for(:controller=>:issues, :action => :edit_gantt, :id=>i.id, :date_from=>@gantt.date_from.strftime("%Y-%m-%d"), :date_to=>@gantt.date_to.strftime("%Y-%m-%d"), :zoom=>zoom, :escape => false) %>', {asynchronous:true, evalScripts:true, onFailure:function(request){handle_failure(request.responseText)}, onSuccess:function(request){change_dates(request.responseText)}, parameters:'due_date=' + encodeURIComponent(value)});
|
|
232 |
})
|
|
233 |
//]]>
|
|
234 |
</script>
|
|
235 |
<% else %>
|
|
236 |
<span style="font-size: 7pt;"><%= format_date(i.start_date) %></span>
|
|
237 |
<% end %>
|
|
238 |
</small></div>
|
|
239 |
<% top = top + 20
|
|
240 |
end %>
|
|
241 |
</div>
|
|
242 |
</td>
|
97 |
243 |
<td>
|
98 |
244 |
|
99 |
|
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
|
|
245 |
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt-container">
|
100 |
246 |
<div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"> </div>
|
101 |
|
<%
|
|
247 |
<%
|
102 |
248 |
#
|
103 |
249 |
# Months headers
|
104 |
250 |
#
|
105 |
251 |
month_f = @gantt.date_from
|
106 |
252 |
left = 0
|
107 |
253 |
height = (show_weeks ? header_heigth : header_heigth + g_height)
|
108 |
|
@gantt.months.times do
|
|
254 |
@gantt.months.times do
|
109 |
255 |
width = ((month_f >> 1) - month_f) * zoom - 1
|
110 |
256 |
%>
|
111 |
257 |
<div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
|
112 |
258 |
<%= link_to "#{month_f.year}-#{month_f.month}", @gantt.params.merge(:year => month_f.year, :month => month_f.month), :title => "#{month_name(month_f.month)} #{month_f.year}"%>
|
113 |
259 |
</div>
|
114 |
|
<%
|
|
260 |
<%
|
115 |
261 |
left = left + width + 1
|
116 |
262 |
month_f = month_f >> 1
|
117 |
263 |
end %>
|
118 |
264 |
|
119 |
|
<%
|
|
265 |
<%
|
120 |
266 |
#
|
121 |
267 |
# Weeks headers
|
122 |
268 |
#
|
... | ... | |
132 |
278 |
width = (7 - @gantt.date_from.cwday + 1) * zoom-1
|
133 |
279 |
%>
|
134 |
280 |
<div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> </div>
|
135 |
|
<%
|
|
281 |
<%
|
136 |
282 |
left = left + width+1
|
137 |
283 |
end %>
|
138 |
284 |
<%
|
... | ... | |
142 |
288 |
<div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
|
143 |
289 |
<small><%= week_f.cweek if width >= 16 %></small>
|
144 |
290 |
</div>
|
145 |
|
<%
|
|
291 |
<%
|
146 |
292 |
left = left + width+1
|
147 |
293 |
week_f = week_f+7
|
148 |
294 |
end
|
149 |
295 |
end %>
|
150 |
296 |
|
151 |
|
<%
|
|
297 |
<%
|
152 |
298 |
#
|
153 |
299 |
# Days headers
|
154 |
300 |
#
|
... | ... | |
156 |
302 |
left = 0
|
157 |
303 |
height = g_height + header_heigth - 1
|
158 |
304 |
wday = @gantt.date_from.cwday
|
159 |
|
(@gantt.date_to - @gantt.date_from + 1).to_i.times do
|
|
305 |
dt = @gantt.date_from
|
|
306 |
(@gantt.date_to - @gantt.date_from + 1).to_i.times do
|
160 |
307 |
width = zoom - 1
|
161 |
308 |
%>
|
162 |
309 |
<div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
|
163 |
|
<%= day_name(wday).first %>
|
|
310 |
<%= "#{dt.day}<br>"if @gantt.zoom == 4 %><%= day_name(wday).first %>
|
164 |
311 |
</div>
|
165 |
|
<%
|
|
312 |
<%
|
166 |
313 |
left = left + width+1
|
167 |
314 |
wday = wday + 1
|
|
315 |
dt = dt + 1
|
168 |
316 |
wday = 1 if wday > 7
|
169 |
317 |
end
|
170 |
318 |
end %>
|
... | ... | |
174 |
322 |
# Tasks
|
175 |
323 |
#
|
176 |
324 |
top = headers_height + 10
|
177 |
|
@gantt.events.each do |i|
|
178 |
|
if i.is_a? Issue
|
179 |
|
i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
|
180 |
|
i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
|
181 |
|
|
182 |
|
i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
|
183 |
|
i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
|
184 |
|
i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
|
185 |
|
|
186 |
|
i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
|
187 |
|
|
188 |
|
i_left = ((i_start_date - @gantt.date_from)*zoom).floor
|
189 |
|
i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
|
190 |
|
d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
|
191 |
|
l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
|
|
325 |
@gantt.events.each do |i|
|
|
326 |
if i.is_a? Issue
|
|
327 |
i_left, i_width, l_width, d_width = get_position(i, @gantt.date_from, @gantt.date_to, zoom)
|
192 |
328 |
%>
|
193 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo"> </div>
|
194 |
|
<% if l_width > 0 %>
|
195 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late"> </div>
|
196 |
|
<% end %>
|
197 |
|
<% if d_width > 0 %>
|
198 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done"> </div>
|
199 |
|
<% end %>
|
200 |
|
<div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
|
201 |
|
<%= i.status.name %>
|
202 |
|
<%= (i.done_ratio).to_i %>%
|
203 |
|
</div>
|
204 |
|
<div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
|
205 |
|
<span class="tip">
|
|
329 |
<div id="ev_<%=i.id%>" style="position:absolute;left:<%= i_left %>px;top:<%= top %>px;padding-top:3px;height:18px;width:<%= i_width+100 %>px;" class="handle">
|
|
330 |
<div id="task_todo_<%=i.id%>" style="float:left:0px; width:<%= i_width %>px;" class="task task_todo"> </div>
|
|
331 |
<div id="task_late_<%=i.id%>" style="float:left:0px; width:<%= l_width %>px;" class="<%= l_width == 0 ? 'task task_none' : 'task task_late' %>"> </div>
|
|
332 |
<div id="task_done_<%=i.id%>" style="float:left:0px; width:<%= d_width %>px;" class="<%= d_width == 0 ? 'task task_none' : 'task task_done' %>"> </div>
|
|
333 |
<div id="task_task_<%=i.id%>" style="position:absolute;left:<%= (i_width + 5) %>px;background:#fff;" class="task">
|
|
334 |
<%= h(i.status.name) %>
|
|
335 |
<%= (i.done_ratio).to_i %>%
|
|
336 |
<% if !i.due_date && i.fixed_version %>
|
|
337 |
- <strong><%= h(i.fixed_version.name) %></strong>
|
|
338 |
<% end %>
|
|
339 |
</div>
|
|
340 |
</div>
|
|
341 |
<%# === tooltip === %>
|
|
342 |
<div id="tt_<%=i.id%>" class="tooltip" style="position: absolute;top:<%= top+14 %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:8px;">
|
|
343 |
<span class="tip" style="position: relative;top:-2px;">
|
206 |
344 |
<%= render_issue_tooltip i %>
|
207 |
345 |
</span></div>
|
208 |
|
<% else
|
|
346 |
<%= draggable_element("ev_#{i.id}",
|
|
347 |
:revert =>false, :scroll=>"'gantt-container'", :constraint => "'horizontal'", :snap=>zoom,
|
|
348 |
:onEnd=>"function( draggable, event ) {issue_moved(draggable.element);}"
|
|
349 |
) %>
|
|
350 |
|
|
351 |
<% else
|
209 |
352 |
i_left = ((i.start_date - @gantt.date_from)*zoom).floor
|
210 |
353 |
%>
|
211 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div>
|
|
354 |
<div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div>
|
212 |
355 |
<div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
|
213 |
356 |
<strong><%= format_version_name i %></strong>
|
214 |
357 |
</div>
|