Skip to content

Commit

Permalink
Dropped support for very buggy drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
michalgritzbach committed Feb 18, 2013
1 parent 56ca728 commit 304eb95
Show file tree
Hide file tree
Showing 43 changed files with 56 additions and 759 deletions.
Empty file modified Gemfile 100644 → 100755
Empty file.
Empty file modified Gemfile.lock 100644 → 100755
Empty file.
Empty file modified README.rdoc 100644 → 100755
Empty file.
184 changes: 12 additions & 172 deletions app/views/gantts/show.html.erb 100644 → 100755
@@ -1,13 +1,5 @@
<% content_for :header_tags do %>
<%= javascript_include_tag "raphael-min.js", :plugin => "redmine_better_gantt_chart" %>
<%= javascript_include_tag "raphael.arrow.js", :plugin => "redmine_better_gantt_chart" %>
<%= javascript_include_tag "jquery.observe_field.js", :plugin => "redmine_better_gantt_chart" %>
<%= stylesheet_link_tag "better_gantt.css", :plugin => "redmine_better_gantt_chart" %>
<% end %>
<% @gantt.view = self %>
<% include_calendar_headers_tags %>
<%= javascript_include_tag "raphael-min.js", :plugin => "redmine_better_gantt_chart" %>
<%= javascript_include_tag "raphael.arrow.js", :plugin => "redmine_better_gantt_chart" %>
<% @gantt.view = self %>
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>

Expand Down Expand Up @@ -48,7 +40,7 @@
zoom = 1
@gantt.zoom.times { zoom = zoom * 2 }

subject_width = 280
subject_width = 330
header_heigth = 18
line_height = 18

Expand Down Expand Up @@ -77,152 +69,11 @@
:zoom => zoom,
:g_width => g_width,
:subject_width => subject_width)
g_height = [(line_height * (@gantt.number_of_rows + 6)) + 0, 208 ].max
g_height = [(line_height * (@gantt.number_of_rows + 2)) + 0, 208 ].max
t_height = g_height + headers_height;
s_height = 24;
%>
<input type="hidden" name="_date_from" id="i_date_from" value="<%= h(@gantt.date_from) %>" />
<input type="hidden" name="_date_to" id="i_date_to" value="<%= h(@gantt.date_to) %>" />
<input type="hidden" name="zm" id="i_zm" value="<%= zoom %>" />
<input type="hidden" name="pzm" id="i_pzm" value="<%= @gantt.zoom %>" />
<script type='text/javascript'>
function issue_moved(elem) {
var id_str = elem.id.substring(3, elem.id.length);
var v_date_from = document.getElementById('i_date_from').getAttribute("value");
var v_date_to = document.getElementById('i_date_to').getAttribute("value");
var v_zm = document.getElementById('i_zm').getAttribute("value");
var v_pzm = document.getElementById('i_pzm').getAttribute("value");
var url_str = '<%= url_for(:controller=>:gantts, :action => :edit_gantt) %>';
url_str = url_str + "/" + id_str;
var day = parseInt(elem.style.left)/parseInt(v_zm);
var jqxhr = $.post(url_str,
'day='+day+'&date_from='+v_date_from+'&date_to='+v_date_to+'&zoom='+v_pzm+"&project_id=<%= @project.to_param %>",
null, 'text')
.success(function(request) { change_dates(request); })
.error(function(request) { handle_failure(request.responseText); });
}

function handle_failure(res_text) {
var text = res_text.split('|');
alert(text[0]);
if (text.length == 1) {
return;
}
change_dates(text[1]);//revert
}

function change_dates(issue_infos) {
if (!issue_infos) {
return;
}
var issue_list = issue_infos.split("|");
for (i = 0; i < issue_list.length; i++) {
change_date(issue_list[i]);
}
window.redrawGanttArrows()
}

function change_date(text) {
if (!text) {
return;
}
var issue_info = text.split("=");
var elem_id = issue_info[0];
var kind = elem_id.substring(0,1);
var preClassName = "";
if (kind == 'v') {
preClassName = "version ";
} else if (kind == 'p') {
preClassName = "project ";
}
var vals = issue_info[1].split(',');
var zoom = document.getElementById('i_zm').getAttribute("value");
//zoom /= var v_zm = document.getElementById('i_zm').getAttribute("value");


var start_date_elem = document.getElementById(elem_id + '_start_date_str');
if (!start_date_elem) {
//target not exists
return;
}
start_date_elem.innerHTML = vals[0];
var tooltip_start_date_elem = document.getElementById('tooltip_start_date_' + elem_id);
if (tooltip_start_date_elem) {
tooltip_start_date_elem.innerHTML = vals[0];
}
var due_date_elem = document.getElementById(elem_id + '_due_date_str');
if (due_date_elem) {
due_date_elem.innerHTML = vals[2];
}

var tooltip_due_date_elem = document.getElementById('tooltip_due_date_' + elem_id);
if (tooltip_due_date_elem) {
tooltip_due_date_elem.innerHTML = vals[2];
}

var ev_elem = document.getElementById('ev_' + elem_id);
if (ev_elem) {
ev_elem.style.left = vals[4] + 'px';
ev_elem.style.width = (parseInt(vals[5])+100)+'px';
}
var todo_elem = document.getElementById('task_todo_' + elem_id);
if (todo_elem) {
todo_elem.style.width = vals[5] + 'px';
}

var late_elem = document.getElementById('task_late_' + elem_id);
if (late_elem) {
var parentStr = "";
if (late_elem.className.indexOf("parent") > 0) parentStr = "parent ";
late_elem.style.width = vals[6] + 'px';
if (vals[6] == '0') {
late_elem.className = preClassName + 'task ' + parentStr + 'task_none';
} else {
late_elem.className = preClassName + 'task ' + parentStr + 'task_late';
}
}
var done_elem = document.getElementById('task_done_' + elem_id);
if (done_elem) {
var parentStr = "";
if (done_elem.className.indexOf("parent") > 0) parentStr = "parent ";
done_elem.style.width = vals[7] + 'px';
if (vals[7] == '0') {
done_elem.className = preClassName + 'task ' + parentStr + 'task_none';
} else {
done_elem.className = preClassName + 'task ' + parentStr + 'task_done';
}
}
var tooltip = document.getElementById("tt_" + elem_id);
if (tooltip) {
tooltip.style.left = ev_elem.style.left;
}

var label = document.getElementById("label_" + elem_id);
if (label) {
label.style.left = (parseInt(vals[4]) + parseInt(vals[5]) + 8) + 'px';
}
var marker_start = document.getElementById("marker_start_" + elem_id);
if (marker_start && vals[8]) {
marker_start.style.left = vals[8] + 'px';
}
var marker_end = document.getElementById("marker_end_" + elem_id);
if (marker_end && vals[9]) {
marker_end.style.left = vals[9] + 'px';
}

//change calendar date
var elm1 = document.getElementById(elem_id+"_hidden_start_date");
if (elm1) elm1.value = vals[1];
var elm2 = document.getElementById(elem_id+"_start_date");
if (elm2) elm2.value = vals[1];
var elm3 = document.getElementById(elem_id+"_hidden_due_date");
if (elm3) elm3.value = vals[3];
var elm4 = document.getElementById(elem_id+"_due_date");
if (elm4) elm4.value = vals[3];
}
</script>

<% if @gantt.truncated %>
<p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
<% end %>
Expand All @@ -234,21 +85,21 @@
style = ""
style += "position:relative;"
style += "height: #{t_height + s_height}px;"
style += "width: #{subject_width - 2}px;"
style += "width: #{subject_width + 1}px;"
%>
<%= content_tag(:div, :style => style) do %>
<%
style = ""
style += "right:-2px;"
style += "width: #{subject_width - 2}px;"
style += "width: #{subject_width}px;"
style += "height: #{headers_height}px;"
style += 'background: #eee;'
%>
<%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
<%
style = ""
style += "right:-2px;"
style += "width: #{subject_width - 2}px;"
style += "width: #{subject_width}px;"
style += "height: #{t_height}px;"
style += 'border-left: 1px solid #c0c0c0;'
style += 'overflow: hidden;'
Expand All @@ -260,24 +111,13 @@
<% end %>
</td>

<% ### Calendar column ### %>
<td style="width:180px; padding:0px;">
<div style="position:relative;height:<%= t_height + 24 %>px;width:180px;">
<div style="width:181px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
<div style="width:181px;height:<%= t_height %>px;overflow:hidden;" class="gantt_hdr"></div>
<div class="gantt_subjects">
<%= @gantt.calendars.html_safe %>
</div>
</div>
</td>
<td>
<div style="position:relative;height:<%= t_height + s_height %>px;overflow-x:auto;overflow-y:hidden;" id="gantt-container">
<div id="gantt_lines" style="position:relative;height:<%= t_height + s_height %>px;overflow:auto;">
<%
style = ""
style += "width: #{g_width - 1}px;"
style += "height: #{headers_height}px;"
style += "background: #eee;"
style += 'background: #eee;'
%>
<%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
Expand All @@ -302,7 +142,7 @@
<% if show_years %>
<%
left = 0
height = (show_weeks ? headers_height : headers_height + g_height)
height = (show_weeks ? header_heigth : header_heigth + g_height)
years = 1
months_remaining = @gantt.months - (12 - @gantt.date_from.month) - 1
years += months_remaining <= 0 ? 0 : (months_remaining / 12).to_i + 1
Expand All @@ -314,7 +154,7 @@
work_days = @gantt.work_days_in(Date.new(year + 1), @gantt.date_from)
months_remaining -= 12 - (@gantt.date_from.month).to_i - 1
elsif months_remaining < 12
work_days = @gantt.work_days_in(Date.new(year, months_remaining, 1), Date.new(year))
work_days = @gantt.work_days_in(Date.new(year, months_remaining+1, 1), Date.new(year))
months_remaining = 0
else
work_days = @gantt.work_days_in(Date.new(year + 1), Date.new(year))
Expand Down Expand Up @@ -489,4 +329,4 @@
<% end %>
<% html_title(l(:label_gantt)) -%>
<%= javascript_tag("window.redrawGanttArrows()") -%>
<%= javascript_tag("window.redrawGanttArrows()") -%>
Empty file modified app/views/issues/_show_estimated_duration.html.erb 100644 → 100755
Empty file.
Empty file modified app/views/settings/_better_gantt_chart_settings.html.erb 100644 → 100755
Empty file.
Empty file modified assets/javascripts/compile_coffee.bat 100644 → 100755
Empty file.
47 changes: 0 additions & 47 deletions assets/javascripts/jquery.observe_field.js

This file was deleted.

Empty file modified assets/javascripts/raphael-min.js 100644 → 100755
Empty file.
21 changes: 7 additions & 14 deletions assets/javascripts/raphael.arrow.coffee 100644 → 100755
Expand Up @@ -59,26 +59,19 @@ Raphael.fn.ganttArrow = (coords, relationType = "follows") ->
Draws connection arrows over the gantt chart
###
window.redrawGanttArrows = () ->
if window.paper?
# remove old paper if it exists
paperDom = paper.canvas
paperDom.parentNode.removeChild(paperDom)
@paper = Raphael("gantt-container", "100%", "100%")
window.paper = paper
paper = Raphael("gantt_lines", "100%", "100%") # check out 'gantt_lines' div, margin-right: -2048px FTW!
paper.clear
# Keep arrows above the "today" marker
window.paper = paper
paper.canvas.style.position = "absolute"
paper.canvas.style.zIndex = "10"
paper.canvas.style.zIndex = "50"

# Relation attributes
relationAttrs = ["follows", "blocked", "duplicated", "relates"]

# Calculates arrow coordinates
calculateAnchors = (from, to) ->
paperX = $(paper.canvas).offset().left
paperY = $(paper.canvas).offset().top
[fromOffsetX, fromOffsetY] = [from.offset().left-paperX, from.offset().top-paperY]
[toOffsetX, toOffsetY] = [to.offset().left-paperX, to.offset().top-paperY]
[fromOffsetX, fromOffsetY] = [from.position().left, from.position().top]
[toOffsetX, toOffsetY] = [to.position().left, to.position().top]
if to.hasClass('parent')
typeOffsetX = 10
else
Expand All @@ -92,8 +85,8 @@ window.redrawGanttArrows = () ->
for relationAttribute in relationAttrs
if (related = element.getAttribute(relationAttribute))
for id in related.split(',')
if (item = $('#task_todo_i'+id))
if (item = $('#'+id))
from = item
to = $('#'+element.id)
if from.offset()? and to.offset()?
if from.position()? and to.position()?
paper.ganttArrow calculateAnchors(from, to), relationAttribute
24 changes: 9 additions & 15 deletions assets/javascripts/raphael.arrow.js 100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion assets/stylesheets/better_gantt.css

This file was deleted.

Empty file modified config/locales/bg.yml 100644 → 100755
Empty file.
1 change: 0 additions & 1 deletion config/locales/en.yml 100644 → 100755
Expand Up @@ -8,4 +8,3 @@ en:
label_disabled: "Disabled"
description_enabled: "a week has 7 working days. Issues can start and finish on weekends when automatically rescheduled. Issue duration includes weekends."
description_disabled: "a week has 5 working days. If start or due date falls on a weekend when the issue is rescheduled automatically, it is moved to the next Monday. Note, that with any value of the setting start and due dates can always be set to a weekend manually."
text_edit_gantt_lack_of_permission: "You do not have permission to edit issues."
Empty file modified config/locales/fr.yml 100644 → 100755
Empty file.

0 comments on commit 304eb95

Please sign in to comment.