|
1 |
<% include_calendar_headers_tags %>
|
1 |
2 |
<% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
|
2 |
3 |
<% if @query.new_record? %>
|
3 |
4 |
<h2><%=l(:label_gantt)%></h2>
|
... | ... | |
49 |
50 |
<% zoom = 1
|
50 |
51 |
@gantt.zoom.times { zoom = zoom * 2 }
|
51 |
52 |
|
52 |
|
subject_width = 330
|
|
53 |
subject_width = 280
|
53 |
54 |
header_heigth = 18
|
54 |
55 |
|
55 |
56 |
headers_height = header_heigth
|
... | ... | |
69 |
70 |
g_height = [(20 * @gantt.events.length + 6)+150, 206].max
|
70 |
71 |
t_height = g_height + headers_height
|
71 |
72 |
%>
|
|
73 |
<input type="hidden" name="_date_from" id="i_date_from" value="<%=h(@gantt.date_from)%>" />
|
|
74 |
<input type="hidden" name="_date_to" id="i_date_to" value="<%=h(@gantt.date_to)%>" />
|
|
75 |
<input type="hidden" name="zm" id="i_zm" value="<%=h(zoom)%>" />
|
|
76 |
<script type='text/javascript'>
|
|
77 |
function issue_moved(elem) {
|
|
78 |
id_str = elem.id.substring(3, elem.id.length);
|
|
79 |
v_date_from = document.getElementById('i_date_from').getAttribute("value");
|
|
80 |
v_date_to = document.getElementById('i_date_to').getAttribute("value");
|
|
81 |
v_zm = document.getElementById('i_zm').getAttribute("value");
|
|
82 |
url_str = '/issues/edit_gantt/' + id_str;
|
|
83 |
day = parseInt(elem.style.left)/parseInt(v_zm);
|
|
84 |
new Ajax.Request(url_str, {asynchronous:true, evalScripts:true,
|
|
85 |
parameters: 'day='+day+'&date_from='+v_date_from+'&date_to='+v_date_to+'&zoom='+v_zm,
|
|
86 |
onSuccess:function(obj) {
|
|
87 |
change_dates(obj.responseText);
|
|
88 |
},
|
|
89 |
onFailure:function(obj) {
|
|
90 |
text = obj.responseText.split('|');
|
|
91 |
alert(text[0]);
|
|
92 |
if (text.length == 1) {
|
|
93 |
return;
|
|
94 |
}
|
|
95 |
change_dates(text[1]);//revert
|
|
96 |
}
|
|
97 |
});
|
|
98 |
|
|
99 |
}
|
|
100 |
|
|
101 |
function change_dates(issue_infos) {
|
|
102 |
issue_list = issue_infos.split("|");
|
|
103 |
for (i = 0; i < issue_list.length; i++) {
|
|
104 |
change_date(issue_list[i]);
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
function change_date(text) {
|
|
109 |
issue_info = text.split("=");
|
|
110 |
elem_id = issue_info[0];
|
|
111 |
vals = issue_info[1].split(',');
|
|
112 |
start_date_elem = document.getElementById(elem_id + '_start_date_str');
|
|
113 |
if (!start_date_elem) {
|
|
114 |
//target not exists
|
|
115 |
return;
|
|
116 |
}
|
|
117 |
start_date_elem.innerHTML = vals[0];
|
|
118 |
tooltip_start_date_elem = document.getElementById('tooltip_start_date_' + elem_id);
|
|
119 |
tooltip_start_date_elem.innerHTML = vals[0];
|
|
120 |
due_date_elem = document.getElementById(elem_id + '_due_date_str');
|
|
121 |
due_date_elem.innerHTML = vals[1];
|
|
122 |
tooltip_due_date_elem = document.getElementById('tooltip_due_date_' + elem_id);
|
|
123 |
tooltip_due_date_elem.innerHTML = vals[1];
|
|
124 |
|
|
125 |
ev_elem = document.getElementById('ev_' + elem_id);
|
|
126 |
ev_elem.style.left = vals[2] + 'px';
|
|
127 |
ev_elem.style.width = (parseInt(vals[3])+100)+'px';
|
|
128 |
todo_elem = document.getElementById('task_todo_' + elem_id);
|
|
129 |
todo_elem.style.width = vals[3] + 'px';
|
|
130 |
late_elem = document.getElementById('task_late_' + elem_id);
|
|
131 |
if (late_elem) {
|
|
132 |
late_elem.style.width = vals[4] + 'px';
|
|
133 |
if (vals[4] == '0') {
|
|
134 |
late_elem.className = 'task task_none';
|
|
135 |
} else {
|
|
136 |
late_elem.className = 'task task_late';
|
|
137 |
}
|
|
138 |
}
|
|
139 |
done_elem = document.getElementById('task_done_' + elem_id);
|
|
140 |
if (done_elem) {
|
|
141 |
done_elem.style.width = vals[5] + 'px';
|
|
142 |
if (vals[5] == '0') {
|
|
143 |
done_elem.className = 'task task_none';
|
|
144 |
} else {
|
|
145 |
done_elem.className = 'task task_done';
|
|
146 |
}
|
|
147 |
}
|
|
148 |
task_elem = document.getElementById('task_task_' + elem_id);
|
|
149 |
if (task_elem) {
|
|
150 |
task_elem.style.left = (parseInt(vals[3])+5) + 'px';
|
|
151 |
}
|
|
152 |
tooltip = document.getElementById("tt_" + elem_id);
|
|
153 |
tooltip.style.left = ev_elem.style.left;
|
|
154 |
//tooltip.style.width = todo_elem.style.width;
|
|
155 |
}
|
|
156 |
</script>
|
72 |
157 |
|
73 |
158 |
<table width="100%" style="border:0; border-collapse: collapse;">
|
74 |
159 |
<tr>
|
... | ... | |
98 |
183 |
end %>
|
99 |
184 |
</div>
|
100 |
185 |
</td>
|
|
186 |
<td style="width:225px; padding:0px;">
|
|
187 |
<div style="position:relative;height:<%= t_height + 24 %>px;width:225px;">
|
|
188 |
<div style="width:225px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
|
|
189 |
<div style="width:225px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
|
|
190 |
<%
|
|
191 |
top = headers_height + 8
|
|
192 |
@gantt.events.each do |i| %>
|
|
193 |
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;"><small>
|
|
194 |
<span id="<%=i.id%>_start_date_str" style="font-size: 7pt;"><%= format_date(i.start_date) %></span>
|
|
195 |
<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 %>
|
|
196 |
<%= observe_field "#{i.id}_start_date",
|
|
197 |
:url => { :controller=>:issues, :action => :edit_gantt, :id=>i.id,
|
|
198 |
:date_from=>@gantt.date_from.strftime("%Y-%m-%d"), :date_to=>@gantt.date_to.strftime("%Y-%m-%d"), :zoom=>zoom },
|
|
199 |
:frequency => 0.25,
|
|
200 |
:with => 'start_date',
|
|
201 |
:success=>"change_dates(request.responseText)",
|
|
202 |
:failure=>"alert(request.responseText)"
|
|
203 |
%>
|
|
204 |
<% if i.is_a? Issue %>
|
|
205 |
<span id="<%=i.id%>_due_date_str" style="font-size: 7pt;<%= "color: blue;" unless i.due_date%>">
|
|
206 |
<%= format_date(i.due_before) %>
|
|
207 |
</span>
|
|
208 |
<input type="hidden" size="12" id="<%=i.id%>_due_date" value="<%= i.due_date %>"><%= calendar_for("#{i.id}_due_date") if i.due_date%>
|
|
209 |
<%= observe_field "#{i.id}_due_date",
|
|
210 |
:url => { :controller=>:issues, :action => :edit_gantt, :id=>i.id,
|
|
211 |
:date_from=>@gantt.date_from.strftime("%Y-%m-%d"), :date_to=>@gantt.date_to.strftime("%Y-%m-%d"), :zoom=>zoom },
|
|
212 |
:frequency => 0.25,
|
|
213 |
:with => 'due_date',
|
|
214 |
:success=>"change_dates(request.responseText)",
|
|
215 |
:failure=>"alert(request.responseText)"
|
|
216 |
%>
|
|
217 |
<% end %>
|
|
218 |
</small></div>
|
|
219 |
<% top = top + 20
|
|
220 |
end %>
|
|
221 |
</div>
|
|
222 |
</td>
|
101 |
223 |
<td>
|
102 |
224 |
|
103 |
|
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
|
|
225 |
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt-container">
|
104 |
226 |
<div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"> </div>
|
105 |
227 |
<%
|
106 |
228 |
#
|
... | ... | |
160 |
282 |
left = 0
|
161 |
283 |
height = g_height + header_heigth - 1
|
162 |
284 |
wday = @gantt.date_from.cwday
|
|
285 |
dt = @gantt.date_from
|
163 |
286 |
(@gantt.date_to - @gantt.date_from + 1).to_i.times do
|
164 |
287 |
width = zoom - 1
|
165 |
288 |
%>
|
166 |
289 |
<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">
|
167 |
|
<%= day_name(wday).first %>
|
|
290 |
<%= "#{dt.day}<br>"if @gantt.zoom == 4 %><%= day_name(wday).first %>
|
168 |
291 |
</div>
|
169 |
292 |
<%
|
170 |
293 |
left = left + width+1
|
171 |
294 |
wday = wday + 1
|
|
295 |
dt = dt + 1
|
172 |
296 |
wday = 1 if wday > 7
|
173 |
297 |
end
|
174 |
298 |
end %>
|
... | ... | |
180 |
304 |
top = headers_height + 10
|
181 |
305 |
@gantt.events.each do |i|
|
182 |
306 |
if i.is_a? Issue
|
183 |
|
i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
|
184 |
|
i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
|
185 |
|
|
186 |
|
i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
|
187 |
|
i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
|
188 |
|
i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
|
189 |
|
|
190 |
|
i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
|
191 |
|
|
192 |
|
i_left = ((i_start_date - @gantt.date_from)*zoom).floor
|
193 |
|
i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
|
194 |
|
d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
|
195 |
|
l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
|
|
307 |
i_left, i_width, l_width, d_width = get_position(i, @gantt.date_from, @gantt.date_to, zoom)
|
196 |
308 |
%>
|
197 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo"> </div>
|
198 |
|
<% if l_width > 0 %>
|
199 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late"> </div>
|
200 |
|
<% end %>
|
201 |
|
<% if d_width > 0 %>
|
202 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done"> </div>
|
203 |
|
<% end %>
|
204 |
|
<div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
|
205 |
|
<%= i.status.name %>
|
206 |
|
<%= (i.done_ratio).to_i %>%
|
207 |
|
</div>
|
208 |
|
<div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
|
209 |
|
<span class="tip">
|
|
309 |
<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">
|
|
310 |
<div id="task_todo_<%=i.id%>" style="float:left:0px; width:<%= i_width %>px;" class="task task_todo"> </div>
|
|
311 |
<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>
|
|
312 |
<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>
|
|
313 |
<div id="task_task_<%=i.id%>" style="position:absolute;left:<%= (i_width + 5) %>px;background:#fff;" class="task">
|
|
314 |
<%= h(i.status.name) %>
|
|
315 |
<%= (i.done_ratio).to_i %>%
|
|
316 |
<% if !i.due_date && i.fixed_version %>
|
|
317 |
- <strong><%= h(i.fixed_version.name) %></strong>
|
|
318 |
<% end %>
|
|
319 |
</div>
|
|
320 |
</div>
|
|
321 |
<% # === tooltip === %>
|
|
322 |
<div id="tt_<%=i.id%>" class="tooltip" style="position: absolute;top:<%= top+14 %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:8px;">
|
|
323 |
<span class="tip" style="position: relative;top:-2px;">
|
210 |
324 |
<%= render_issue_tooltip i %>
|
211 |
325 |
</span></div>
|
|
326 |
<%= draggable_element("ev_#{i.id}",
|
|
327 |
:revert =>false, :scroll=>"'gantt-container'", :constraint => "'horizontal'", :snap=>zoom,
|
|
328 |
:onEnd=>"function( draggable, event ) {issue_moved(draggable.element);}"
|
|
329 |
) %>
|
|
330 |
|
212 |
331 |
<% else
|
213 |
332 |
i_left = ((i.start_date - @gantt.date_from)*zoom).floor
|
214 |
333 |
%>
|
215 |
|
<div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div>
|
|
334 |
<div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div>
|
216 |
335 |
<div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
|
217 |
336 |
<%= h("#{i.project} -") unless @project && @project == i.project %>
|
218 |
337 |
<strong><%=h i %></strong>
|