70 |
70 |
|
71 |
71 |
@subjects = ''
|
72 |
72 |
@lines = ''
|
|
73 |
@calendars = ''
|
73 |
74 |
@number_of_rows = nil
|
74 |
75 |
|
75 |
76 |
@issue_ancestors = []
|
... | ... | |
129 |
130 |
@lines
|
130 |
131 |
end
|
131 |
132 |
|
|
133 |
# Renders the calendars of the Gantt chart, the right side
|
|
134 |
def calendars(options={})
|
|
135 |
render(options.merge(:only => :calendars)) unless @calendars_rendered
|
|
136 |
@calendars
|
|
137 |
end
|
|
138 |
|
132 |
139 |
# Returns issues that will be rendered
|
133 |
140 |
def issues
|
134 |
141 |
@issues ||= @query.issues(
|
... | ... | |
175 |
182 |
options = {:top => 0, :top_increment => 20, :indent_increment => 20, :render => :subject, :format => :html}.merge(options)
|
176 |
183 |
indent = options[:indent] || 4
|
177 |
184 |
|
178 |
|
@subjects = '' unless options[:only] == :lines
|
179 |
|
@lines = '' unless options[:only] == :subjects
|
|
185 |
if options[:format] == :html
|
|
186 |
@subjects = '' unless options[:only] == :lines && options[:only] == :calendars
|
|
187 |
@lines = '' unless options[:only] == :subjects && options[:only] == :calendars
|
|
188 |
@calendars = '' unless options[:only] == :lines && options[:only] == :subjects
|
|
189 |
else
|
|
190 |
@subjects = '' unless options[:only] == :lines
|
|
191 |
@lines = '' unless options[:only] == :subjects
|
|
192 |
end
|
|
193 |
|
180 |
194 |
@number_of_rows = 0
|
181 |
195 |
|
182 |
196 |
Project.project_tree(projects) do |project, level|
|
... | ... | |
185 |
199 |
break if abort?
|
186 |
200 |
end
|
187 |
201 |
|
188 |
|
@subjects_rendered = true unless options[:only] == :lines
|
189 |
|
@lines_rendered = true unless options[:only] == :subjects
|
190 |
|
|
|
202 |
if options[:format] == :html
|
|
203 |
@subjects_rendered = true unless options[:only] == :lines && options[:only] == :calendars
|
|
204 |
@lines_rendered = true unless options[:only] == :subjects && options[:only] == :calendars
|
|
205 |
@calendars_rendered = true unless options[:only] == :lines && options[:only] == :subjects
|
|
206 |
else
|
|
207 |
@subjects_rendered = true unless options[:only] == :lines
|
|
208 |
@lines_rendered = true unless options[:only] == :subjects
|
|
209 |
end
|
191 |
210 |
render_end(options)
|
192 |
211 |
end
|
193 |
212 |
|
194 |
213 |
def render_project(project, options={})
|
195 |
|
subject_for_project(project, options) unless options[:only] == :lines
|
196 |
|
line_for_project(project, options) unless options[:only] == :subjects
|
197 |
|
|
|
214 |
if options[:format] == :html
|
|
215 |
subject_for_project(project, options) unless options[:only] == :lines && options[:only] == :calendars
|
|
216 |
line_for_project(project, options) unless options[:only] == :subjects && options[:only] == :calendars
|
|
217 |
calendar_for_project(project, options) unless options[:only] == :lines && options[:only] == :subjects
|
|
218 |
else
|
|
219 |
subject_for_project(project, options) unless options[:only] == :lines
|
|
220 |
line_for_project(project, options) unless options[:only] == :subjects
|
|
221 |
end
|
198 |
222 |
options[:top] += options[:top_increment]
|
199 |
223 |
options[:indent] += options[:indent_increment]
|
200 |
224 |
@number_of_rows += 1
|
... | ... | |
218 |
242 |
|
219 |
243 |
def render_issues(issues, options={})
|
220 |
244 |
@issue_ancestors = []
|
221 |
|
|
222 |
245 |
issues.each do |i|
|
223 |
|
subject_for_issue(i, options) unless options[:only] == :lines
|
224 |
|
line_for_issue(i, options) unless options[:only] == :subjects
|
225 |
|
|
|
246 |
if options[:format] == :html
|
|
247 |
subject_for_issue(i, options) unless options[:only] == :lines && options[:only] == :calendars
|
|
248 |
line_for_issue(i, options) unless options[:only] == :subjects && options[:only] == :calendars
|
|
249 |
calendar_for_issue(i, options) unless options[:only] == :lines && options[:only] == :subjects
|
|
250 |
else
|
|
251 |
subject_for_issue(i, options) unless options[:only] == :lines
|
|
252 |
line_for_issue(i, options) unless options[:only] == :subjects
|
|
253 |
end
|
226 |
254 |
options[:top] += options[:top_increment]
|
227 |
255 |
@number_of_rows += 1
|
228 |
256 |
break if abort?
|
... | ... | |
233 |
261 |
|
234 |
262 |
def render_version(project, version, options={})
|
235 |
263 |
# Version header
|
236 |
|
subject_for_version(version, options) unless options[:only] == :lines
|
237 |
|
line_for_version(version, options) unless options[:only] == :subjects
|
238 |
|
|
|
264 |
if options[:format] == :html
|
|
265 |
subject_for_version(version, options) unless options[:only] == :lines && options[:only] == :calendars
|
|
266 |
line_for_version(version, options) unless options[:only] == :subjects && options[:only] == :calendars
|
|
267 |
calendar_for_version(version, options) unless options[:only] == :lines && options[:only] == :subjects
|
|
268 |
else
|
|
269 |
subject_for_version(version, options) unless options[:only] == :lines
|
|
270 |
line_for_version(version, options) unless options[:only] == :subjects
|
|
271 |
end
|
239 |
272 |
options[:top] += options[:top_increment]
|
240 |
273 |
@number_of_rows += 1
|
241 |
274 |
return if abort?
|
... | ... | |
283 |
316 |
|
284 |
317 |
case options[:format]
|
285 |
318 |
when :html
|
286 |
|
html_task(options, coords, :css => "project task", :label => label, :markers => true)
|
|
319 |
html_task(options, coords, :css => "project task", :label => label, :markers => true, :id => project.id, :kind => "p")
|
287 |
320 |
when :image
|
288 |
321 |
image_task(options, coords, :label => label, :markers => true, :height => 3)
|
289 |
322 |
when :pdf
|
... | ... | |
322 |
355 |
|
323 |
356 |
case options[:format]
|
324 |
357 |
when :html
|
325 |
|
html_task(options, coords, :css => "version task", :label => label, :markers => true)
|
|
358 |
html_task(options, coords, :css => "version task", :label => label, :markers => true, :id => version.id, :kind => "v")
|
326 |
359 |
when :image
|
327 |
360 |
image_task(options, coords, :label => label, :markers => true, :height => 3)
|
328 |
361 |
when :pdf
|
... | ... | |
346 |
379 |
css_classes << ' issue-overdue' if issue.overdue?
|
347 |
380 |
css_classes << ' issue-behind-schedule' if issue.behind_schedule?
|
348 |
381 |
css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
|
349 |
|
|
350 |
382 |
subject = "<span class='#{css_classes}'>".html_safe
|
351 |
383 |
if issue.assigned_to.present?
|
352 |
384 |
assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
|
... | ... | |
375 |
407 |
if issue.is_a?(Issue) && issue.due_before
|
376 |
408 |
coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom])
|
377 |
409 |
label = "#{ issue.status.name } #{ issue.done_ratio }%"
|
378 |
|
|
|
410 |
if !issue.due_date && issue.fixed_version
|
|
411 |
if options[:format] == :html
|
|
412 |
label += "- <strong>#{h(issue.fixed_version.name)}</strong>"
|
|
413 |
else
|
|
414 |
label += "-#{h(issue.fixed_version.name)}"
|
|
415 |
end
|
|
416 |
end
|
379 |
417 |
case options[:format]
|
380 |
418 |
when :html
|
381 |
|
html_task(options, coords, :css => "task " + (issue.leaf? ? 'leaf' : 'parent'), :label => label, :issue => issue, :markers => !issue.leaf?)
|
|
419 |
html_task(options, coords, :css => "task " + (issue.leaf? ? 'leaf' : 'parent'),
|
|
420 |
:label => label, :issue => issue, :markers => !issue.leaf?, :id => issue.id, :kind => "i")
|
382 |
421 |
when :image
|
383 |
422 |
image_task(options, coords, :label => label)
|
384 |
423 |
when :pdf
|
... | ... | |
618 |
657 |
pdf.Output
|
619 |
658 |
end
|
620 |
659 |
|
|
660 |
def edit(pms)
|
|
661 |
id = pms[:id]
|
|
662 |
kind = id.slice!(0).chr
|
|
663 |
begin
|
|
664 |
case kind
|
|
665 |
when 'i'
|
|
666 |
@issue = Issue.find(pms[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
|
667 |
when 'p'
|
|
668 |
@issue = Project.find(pms[:id])
|
|
669 |
when 'v'
|
|
670 |
@issue = Version.find(pms[:id], :include => [:project])
|
|
671 |
end
|
|
672 |
rescue ActiveRecord::RecordNotFound
|
|
673 |
return "issue not found : #{pms[:id]}", 400
|
|
674 |
end
|
|
675 |
|
|
676 |
if !@issue.start_date || !@issue.due_before
|
|
677 |
#render :text=>l(:notice_locking_conflict), :status=>400
|
|
678 |
return l(:notice_locking_conflict), 400
|
|
679 |
end
|
|
680 |
@issue.init_journal(User.current)
|
|
681 |
date_from = Date.parse(pms[:date_from])
|
|
682 |
old_start_date = @issue.start_date
|
|
683 |
o = get_issue_position(@issue, pms[:zoom])
|
|
684 |
text_for_revert = "#{kind}#{id}=#{format_date(@issue.start_date)},#{@issue.start_date},#{format_date(@issue.due_before)},#{@issue.due_before},#{o[0]},#{o[1]},#{o[2]},#{o[3]}".html_safe
|
|
685 |
|
|
686 |
if pms[:day]
|
|
687 |
#bar moved
|
|
688 |
day = pms[:day].to_i
|
|
689 |
duration = @issue.due_before - @issue.start_date
|
|
690 |
@issue.start_date = date_from + day
|
|
691 |
@issue.due_date = @issue.start_date + duration.to_i if @issue.due_date
|
|
692 |
elsif pms[:start_date]
|
|
693 |
#start date changed
|
|
694 |
start_date = Date.parse(pms[:start_date])
|
|
695 |
if @issue.start_date == start_date
|
|
696 |
#render :text=>""
|
|
697 |
return "", 200 #nothing has changed
|
|
698 |
end
|
|
699 |
@issue.start_date = start_date
|
|
700 |
@issue.due_date = start_date if @issue.due_date && start_date > @issue.due_date
|
|
701 |
elsif pms[:due_date]
|
|
702 |
#due date changed
|
|
703 |
due_date = Date.parse(pms[:due_date])
|
|
704 |
if @issue.due_date == due_date
|
|
705 |
#render :text=>""
|
|
706 |
return "", 200 #nothing has changed
|
|
707 |
end
|
|
708 |
@issue.due_date = due_date
|
|
709 |
@issue.start_date = due_date if due_date < @issue.start_date
|
|
710 |
end
|
|
711 |
fv = @issue.fixed_version
|
|
712 |
if fv && fv.effective_date && !@issue.due_date && fv.effective_date < @issue.start_date
|
|
713 |
@issue.start_date = old_start_date
|
|
714 |
end
|
|
715 |
|
|
716 |
begin
|
|
717 |
@issue.save!
|
|
718 |
o = get_issue_position(@issue, pms[:zoom])
|
|
719 |
text = "#{kind}#{id}=#{format_date(@issue.start_date)},#{@issue.start_date},#{format_date(@issue.due_before)},#{@issue.due_before},#{o[0]},#{o[1]},#{o[2]},#{o[3]}".html_safe
|
|
720 |
|
|
721 |
prj_map = {}
|
|
722 |
text = set_project_data(@issue.project, pms[:zoom], text, prj_map)
|
|
723 |
version_map = {}
|
|
724 |
text = set_version_data(@issue.fixed_version, pms[:zoom], text, version_map)
|
|
725 |
|
|
726 |
#check dependencies
|
|
727 |
issues = @issue.all_precedes_issues
|
|
728 |
issues.each do |i|
|
|
729 |
o = get_issue_position(i, pms[:zoom])
|
|
730 |
text += "|i#{i.id}=#{format_date(i.start_date)},#{i.start_date},#{format_date(i.due_before)},#{i.due_before},#{o[0]},#{o[1]},#{o[2]},#{o[3]}".html_safe
|
|
731 |
text = set_project_data(i.project, pms[:zoom], text, prj_map)
|
|
732 |
text = set_version_data(i.fixed_version, pms[:zoom], text, version_map)
|
|
733 |
end
|
|
734 |
|
|
735 |
#check parent
|
|
736 |
is = @issue
|
|
737 |
while
|
|
738 |
pid = is.parent_issue_id
|
|
739 |
break if !pid
|
|
740 |
i = Issue.find(pid)
|
|
741 |
o = get_issue_position(i, pms[:zoom])
|
|
742 |
text += "|i#{i.id}=#{format_date(i.start_date)},#{i.start_date},#{format_date(i.due_before)},#{i.due_before},#{o[0]},#{o[1]},#{o[2]},#{o[3]},#{o[4]},#{o[5]}".html_safe
|
|
743 |
text = set_project_data(i.project, pms[:zoom], text, prj_map)
|
|
744 |
text = set_version_data(i.fixed_version, pms[:zoom], text, version_map)
|
|
745 |
is = i
|
|
746 |
end
|
|
747 |
#render :text=>text
|
|
748 |
return text, 200
|
|
749 |
rescue => e
|
|
750 |
#render :text=>@issue.errors.full_messages.join("\n") + "|" + text_for_revert , :status=>400
|
|
751 |
if @issue.errors.full_messages.to_s == ""
|
|
752 |
return e.to_s + "\n" + [$!,$@.join("\n")].join("\n") + "\n" + @issue.errors.full_messages.join("\n") + "|" + text_for_revert, 400
|
|
753 |
else
|
|
754 |
return @issue.errors.full_messages.join("\n") + "|" + text_for_revert, 400
|
|
755 |
end
|
|
756 |
end
|
|
757 |
end
|
|
758 |
|
621 |
759 |
private
|
622 |
760 |
|
623 |
761 |
def coordinates(start_date, end_date, progress, zoom=nil)
|
... | ... | |
737 |
875 |
output = ''
|
738 |
876 |
# Renders the task bar, with progress and late
|
739 |
877 |
if coords[:bar_start] && coords[:bar_end]
|
740 |
|
output << "<div style='top:#{ params[:top] }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] - 2}px;' class='#{options[:css]} task_todo'> </div>".html_safe
|
|
878 |
i_width = coords[:bar_end] - coords[:bar_start] - 2
|
|
879 |
output << "<div id='ev_#{options[:kind]}#{options[:id]}' style='position:absolute;left:#{coords[:bar_start]}px;top:#{params[:top]}px;padding-top:3px;height:18px;width:#{ i_width + 100}px;' #{options[:kind] == 'i' ? "class='handle'" : ""}>".html_safe
|
|
880 |
output << "<div id='task_todo_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:#{ i_width}px;' class='#{options[:css]} task_todo'> </div>".html_safe
|
741 |
881 |
|
742 |
882 |
if coords[:bar_late_end]
|
743 |
|
output << "<div style='top:#{ params[:top] }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_late_end] - coords[:bar_start] - 2}px;' class='#{options[:css]} task_late'> </div>".html_safe
|
|
883 |
l_width = coords[:bar_late_end] - coords[:bar_start] - 2
|
|
884 |
output << "<div id='task_late_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:#{ l_width}px;' class='#{ l_width == 0 ? options[:css] + " task_none" : options[:css] + " task_late"}'> </div>".html_safe
|
|
885 |
else
|
|
886 |
output << "<div id='task_late_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:0px;' class='#{ options[:css] + " task_none"}'> </div>".html_safe
|
744 |
887 |
end
|
745 |
888 |
if coords[:bar_progress_end]
|
746 |
|
output << "<div style='top:#{ params[:top] }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_progress_end] - coords[:bar_start] - 2}px;' class='#{options[:css]} task_done'> </div>".html_safe
|
|
889 |
d_width = coords[:bar_progress_end] - coords[:bar_start] - 2
|
|
890 |
output << "<div id='task_done_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:#{ d_width}px;' class='#{ d_width == 0 ? options[:css] + " task_none" : options[:css] + " task_done"}'> </div>".html_safe
|
|
891 |
else
|
|
892 |
output << "<div id='task_done_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:0px;' class='#{ options[:css] + " task_none"}'> </div>".html_safe
|
747 |
893 |
end
|
|
894 |
output << "</div>".html_safe
|
|
895 |
else
|
|
896 |
output << "<div id='ev_#{options[:kind]}#{options[:id]}' style='position:absolute;left:0px;top:#{params[:top]}px;padding-top:3px;height:18px;width:0px;' #{options[:kind] == 'i' ? "class='handle'" : ""}>".html_safe
|
|
897 |
output << "<div id='task_todo_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:0px;' class='#{ options[:css]} task_todo'> </div>".html_safe
|
|
898 |
output << "<div id='task_late_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:0px;' class='#{ options[:css] + " task_none"}'> </div>".html_safe
|
|
899 |
output << "<div id='task_done_#{options[:kind]}#{options[:id]}' style='float:left:0px; width:0px;' class='#{ options[:css] + " task_none"}'> </div>".html_safe
|
|
900 |
output << "</div>".html_safe
|
748 |
901 |
end
|
749 |
902 |
# Renders the markers
|
750 |
903 |
if options[:markers]
|
751 |
904 |
if coords[:start]
|
752 |
|
output << "<div style='top:#{ params[:top] }px;left:#{ coords[:start] }px;width:15px;' class='#{options[:css]} marker starting'> </div>".html_safe
|
|
905 |
output << "<div id='marker_start_#{options[:kind]}#{options[:id]}' style='top:#{ params[:top] }px;left:#{ coords[:start] }px;width:15px;' class='#{options[:css]} marker starting'> </div>".html_safe
|
753 |
906 |
end
|
754 |
907 |
if coords[:end]
|
755 |
|
output << "<div style='top:#{ params[:top] }px;left:#{ coords[:end] + params[:zoom] }px;width:15px;' class='#{options[:css]} marker ending'> </div>".html_safe
|
|
908 |
output << "<div id='marker_end_#{options[:kind]}#{options[:id]}' style='top:#{ params[:top] }px;left:#{ coords[:end] + params[:zoom] }px;width:15px;' class='#{options[:css]} marker ending'> </div>".html_safe
|
756 |
909 |
end
|
|
910 |
else
|
|
911 |
output << view.draggable_element("ev_#{options[:kind]}#{options[:id]}", :revert =>false, :scroll=>"'gantt-container'", :constraint => "'horizontal'", :snap=>params[:zoom],:onEnd=>'function( draggable, event ) {issue_moved(draggable.element);}') #pend
|
757 |
912 |
end
|
758 |
913 |
# Renders the label on the right
|
759 |
914 |
if options[:label]
|
760 |
|
output << "<div style='top:#{ params[:top] }px;left:#{ (coords[:bar_end] || 0) + 8 }px;' class='#{options[:css]} label'>".html_safe
|
|
915 |
output << "<div id='label_#{options[:kind]}#{options[:id]}' style='top:#{ params[:top] }px;left:#{ (coords[:bar_end] || 0) + 8 }px;' class='#{options[:css]} label'>".html_safe
|
761 |
916 |
output << options[:label]
|
762 |
917 |
output << "</div>".html_safe
|
763 |
918 |
end
|
764 |
919 |
# Renders the tooltip
|
765 |
920 |
if options[:issue] && coords[:bar_start] && coords[:bar_end]
|
766 |
|
output << "<div class='tooltip' style='position: absolute;top:#{ params[:top] }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] }px;height:12px;'>".html_safe
|
|
921 |
output << "<div id='tt_#{options[:kind]}#{options[:id]}' class='tooltip' style='position: absolute;top:#{ params[:top] }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] }px;height:12px;'>".html_safe
|
767 |
922 |
output << '<span class="tip">'.html_safe
|
768 |
923 |
output << view.render_issue_tooltip(options[:issue]).html_safe
|
769 |
924 |
output << "</span></div>".html_safe
|
... | ... | |
855 |
1010 |
params[:image].text(params[:subject_width] + (coords[:bar_end] || 0) + 5,params[:top] + 1, options[:label])
|
856 |
1011 |
end
|
857 |
1012 |
end
|
|
1013 |
|
|
1014 |
## for edit gantt
|
|
1015 |
def set_project_data(prj, zoom, text, prj_map = {})
|
|
1016 |
if !prj
|
|
1017 |
return text
|
|
1018 |
end
|
|
1019 |
if !prj_map[prj.id]
|
|
1020 |
o = get_project_position(prj, zoom)
|
|
1021 |
text += "|p#{prj.id}=#{format_date(prj.start_date)},#{prj.start_date},#{format_date(prj.due_date)},#{prj.due_date},#{o[0]},#{o[1]},#{o[2]},#{o[3]},#{o[4]},#{o[5]}"
|
|
1022 |
prj_map[prj.id] = prj
|
|
1023 |
end
|
|
1024 |
text = set_project_data(prj.parent, zoom, text, prj_map)
|
|
1025 |
end
|
|
1026 |
|
|
1027 |
def set_version_data(version, zoom, text, version_map = {})
|
|
1028 |
if !version
|
|
1029 |
return text
|
|
1030 |
end
|
|
1031 |
if !version_map[version.id]
|
|
1032 |
o = get_version_position(version, zoom)
|
|
1033 |
text += "|v#{version.id}=#{format_date(version.start_date)},#{version.start_date},#{format_date(version.due_date)},#{version.due_date},#{o[0]},#{o[1]},#{o[2]},#{o[3]},#{o[4]},#{o[5]}"
|
|
1034 |
version_map[version.id] = version
|
|
1035 |
end
|
|
1036 |
return text
|
|
1037 |
end
|
|
1038 |
|
|
1039 |
def get_pos(coords)
|
|
1040 |
i_left = 0
|
|
1041 |
i_width = 0
|
|
1042 |
l_width = 0
|
|
1043 |
d_width = 0
|
|
1044 |
if coords[:bar_start]
|
|
1045 |
i_left = coords[:bar_start]
|
|
1046 |
if coords[:bar_end]
|
|
1047 |
i_width = coords[:bar_end] - coords[:bar_start] - 2
|
|
1048 |
i_width = 0 if i_width < 0
|
|
1049 |
end
|
|
1050 |
if coords[:bar_late_end]
|
|
1051 |
l_width = coords[:bar_late_end] - coords[:bar_start] - 2
|
|
1052 |
end
|
|
1053 |
if coords[:bar_progress_end]
|
|
1054 |
d_width = coords[:bar_progress_end] - coords[:bar_start] - 2
|
|
1055 |
end
|
|
1056 |
end
|
|
1057 |
return i_left, i_width, l_width, d_width
|
|
1058 |
end
|
|
1059 |
|
|
1060 |
def get_issue_position(issue, zoom_str)
|
|
1061 |
z = zoom_str.to_i
|
|
1062 |
zoom = 1
|
|
1063 |
z.times { zoom = zoom * 2}
|
|
1064 |
id = issue.due_before
|
|
1065 |
if id && @date_to < id
|
|
1066 |
id = @date_to
|
|
1067 |
end
|
|
1068 |
coords = coordinates(issue.start_date, id, issue.done_ratio, zoom)
|
|
1069 |
|
|
1070 |
i_left, i_width, l_width, d_width = get_pos(coords)
|
|
1071 |
if coords[:end]
|
|
1072 |
return i_left, i_width, l_width, d_width, coords[:start], coords[:end] + zoom
|
|
1073 |
else
|
|
1074 |
return i_left, i_width, l_width, d_width, coords[:start], nil
|
|
1075 |
end
|
|
1076 |
end
|
|
1077 |
|
|
1078 |
def get_project_position(project, zoom_str)
|
|
1079 |
z = zoom_str.to_i
|
|
1080 |
zoom = 1
|
|
1081 |
z.times { zoom = zoom * 2}
|
|
1082 |
pd = project.due_date
|
|
1083 |
if pd && @date_to < pd
|
|
1084 |
pd = @date_to
|
|
1085 |
end
|
|
1086 |
coords = coordinates(project.start_date, pd, nil, zoom)
|
|
1087 |
i_left, i_width, l_width, d_width = get_pos(coords)
|
|
1088 |
if coords[:end]
|
|
1089 |
return i_left, i_width, l_width, d_width, coords[:start], coords[:end] + zoom
|
|
1090 |
else
|
|
1091 |
return i_left, i_width, l_width, d_width, coords[:start], nil
|
|
1092 |
end
|
|
1093 |
end
|
|
1094 |
|
|
1095 |
def get_version_position(version, zoom_str)
|
|
1096 |
z = zoom_str.to_i
|
|
1097 |
zoom = 1
|
|
1098 |
z.times { zoom = zoom * 2}
|
|
1099 |
vd = version.due_date
|
|
1100 |
if vd && @date_to < vd
|
|
1101 |
vd = @date_to
|
|
1102 |
end
|
|
1103 |
coords = coordinates(version.start_date, vd, version.completed_pourcent, zoom)
|
|
1104 |
i_left, i_width, l_width, d_width = get_pos(coords)
|
|
1105 |
if coords[:end]
|
|
1106 |
return i_left, i_width, l_width, d_width, coords[:start], coords[:end] + zoom
|
|
1107 |
else
|
|
1108 |
return i_left, i_width, l_width, d_width, coords[:start], nil
|
|
1109 |
end
|
|
1110 |
end
|
|
1111 |
|
|
1112 |
def calendar_for_issue(issue, options)
|
|
1113 |
# Skip issues that don't have a due_before (due_date or version's due_date)
|
|
1114 |
if issue.is_a?(Issue) && issue.due_before
|
|
1115 |
|
|
1116 |
case options[:format]
|
|
1117 |
when :html
|
|
1118 |
@calendars << "<div style='position: absolute;line-height:1.2em;height:16px;top:#{options[:top]}px;left:4px;overflow:hidden;'>"
|
|
1119 |
start_date = issue.start_date
|
|
1120 |
if start_date
|
|
1121 |
@calendars << "<span id='i#{issue.id}_start_date_str'>"
|
|
1122 |
@calendars << format_date(start_date)
|
|
1123 |
@calendars << "</span>"
|
|
1124 |
@calendars << "<input type='hidden' size='12' id='i#{issue.id}_hidden_start_date' value='#{start_date}' />"
|
|
1125 |
if issue.leaf?
|
|
1126 |
@calendars << "<input type='hidden' size='12' id='i#{issue.id}_start_date' value='#{start_date}' />#{view.g_calendar_for('i' + issue.id.to_s + '_start_date')}"
|
|
1127 |
else
|
|
1128 |
@calendars << "<input type='hidden' size='12' id='i#{issue.id}_start_date' value='#{start_date}' /> "
|
|
1129 |
end
|
|
1130 |
@calendars << observe_date_field("i#{issue.id}", 'start')
|
|
1131 |
end
|
|
1132 |
due_date = issue.due_date
|
|
1133 |
if due_date
|
|
1134 |
@calendars << "<span id='i#{issue.id}_due_date_str'>"
|
|
1135 |
@calendars << format_date(due_date)
|
|
1136 |
@calendars << "</span>"
|
|
1137 |
@calendars << "<input type='hidden' size='12' id='i#{issue.id}_hidden_due_date' value='#{due_date}' />"
|
|
1138 |
if issue.leaf?
|
|
1139 |
@calendars << "<input type='hidden' size='12' id='i#{issue.id}_due_date' value='#{due_date}' />#{view.g_calendar_for('i' + issue.id.to_s + '_due_date')}"
|
|
1140 |
else
|
|
1141 |
@calendars << "<input type='hidden' size='12' id='i#{issue.id}_due_date' value='#{due_date}' />"
|
|
1142 |
end
|
|
1143 |
@calendars << observe_date_field("i#{issue.id}", 'due')
|
|
1144 |
end
|
|
1145 |
@calendars << "</div>"
|
|
1146 |
when :image
|
|
1147 |
#nop
|
|
1148 |
when :pdf
|
|
1149 |
#nop
|
|
1150 |
end
|
|
1151 |
else
|
|
1152 |
ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before"
|
|
1153 |
''
|
|
1154 |
end
|
|
1155 |
end
|
|
1156 |
|
|
1157 |
def calendar_for_version(version, options)
|
|
1158 |
# Skip version that don't have a due_before (due_date or version's due_date)
|
|
1159 |
if version.is_a?(Version) && version.start_date && version.due_date
|
|
1160 |
|
|
1161 |
case options[:format]
|
|
1162 |
when :html
|
|
1163 |
@calendars << "<div style='position: absolute;line-height:1.2em;height:16px;top:#{options[:top]}px;left:4px;overflow:hidden;'>"
|
|
1164 |
@calendars << "<span id='v#{version.id}_start_date_str'>"
|
|
1165 |
@calendars << format_date(version.effective_date)
|
|
1166 |
@calendars << "</span>"
|
|
1167 |
@calendars << "</div>"
|
|
1168 |
when :image
|
|
1169 |
#nop
|
|
1170 |
when :pdf
|
|
1171 |
#nop
|
|
1172 |
end
|
|
1173 |
else
|
|
1174 |
ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before"
|
|
1175 |
''
|
|
1176 |
end
|
|
1177 |
end
|
|
1178 |
|
|
1179 |
def calendar_for_project(project, options)
|
|
1180 |
case options[:format]
|
|
1181 |
when :html
|
|
1182 |
@calendars << "<div style='position: absolute;line-height:1.2em;height:16px;top:#{options[:top]}px;left:4px;overflow:hidden;'>"
|
|
1183 |
@calendars << "<span id='p#{project.id}_start_date_str'>"
|
|
1184 |
@calendars << format_date(project.start_date) if project.start_date
|
|
1185 |
@calendars << "</span>"
|
|
1186 |
@calendars << " "
|
|
1187 |
@calendars << "<span id='p#{project.id}_due_date_str'>"
|
|
1188 |
@calendars << format_date(project.due_date) if project.due_date
|
|
1189 |
@calendars << "</span>"
|
|
1190 |
@calendars << "</div>"
|
|
1191 |
when :image
|
|
1192 |
# nop
|
|
1193 |
when :pdf
|
|
1194 |
# nop
|
|
1195 |
end
|
|
1196 |
end
|
|
1197 |
|
|
1198 |
def observe_date_field(id, type)
|
|
1199 |
output = ''
|
|
1200 |
prj_id = ''
|
|
1201 |
prj_id = @project.to_param if @project
|
|
1202 |
output << "<script type='text/javascript'>\n"
|
|
1203 |
output << "//<![CDATA[\n"
|
|
1204 |
output << "new Form.Element.Observer('#{id}_#{type}_date', 0.25,\n"
|
|
1205 |
output << " function(element, value) {\n"
|
|
1206 |
output << " if (value == document.getElementById('#{id}_hidden_#{type}_date').value) {\n"
|
|
1207 |
output << " return ;\n"
|
|
1208 |
output << " }\n"
|
|
1209 |
output << " new Ajax.Request('#{view.url_for(:controller=>:gantts, :action => :edit_gantt, :id=>id, :date_from=>self.date_from.strftime("%Y-%m-%d"), :date_to=>self.date_to.strftime("%Y-%m-%d"), :zoom=>self.zoom, :escape => false, :project_id=>prj_id)}', {asynchronous:true, evalScripts:true, onFailure:function(request){handle_failure(request.responseText)}, onSuccess:function(request){change_dates(request.responseText)}, parameters:'#{type}_date=' + encodeURIComponent(value)});"
|
|
1210 |
output << " })\n"
|
|
1211 |
output << "//]]>\n"
|
|
1212 |
output << "</script>"
|
|
1213 |
end
|
858 |
1214 |
end
|
859 |
1215 |
end
|
860 |
1216 |
end
|