diff --git a/app/controllers/planning_controller.rb b/app/controllers/planning_controller.rb
index c49582a..6b7c384 100644
--- a/app/controllers/planning_controller.rb
+++ b/app/controllers/planning_controller.rb
@@ -85,6 +85,7 @@ def add_issue(issue)
:project_name => prj[:name],
:tracker => tracker,
:name => issue[:subject],
+ :estimated_time => issue[:estimated_hours],
:description => issue[:description],
:leaf => issue.leaf?,
:parent => issue.parent_issue_id,
diff --git a/assets/javascripts/planning.js b/assets/javascripts/planning.js
index c377e39..f3b62d4 100644
--- a/assets/javascripts/planning.js
+++ b/assets/javascripts/planning.js
@@ -250,6 +250,7 @@ PlanningIssue.prototype._showTooltip = function ()
'
' + this.t('parent_task') + ': | ' + parent_issue + ' |
' +
'' + this.t('start_date') + ': | ' + this.chart.formatDate(this.start_date) + ' |
' +
'' + this.t('due_date') + ': | ' + this.chart.formatDate(this.due_date) + ' |
' +
+ '' + this.t('est_time') + ': | ' + this.estimated_time + ' |
' +
'' + this.t('leaf_task') + ': | ' + (this.leaf ? this.t('yes') : this.t('no')) + ' |
' +
'' + this.t('is_closed') + ': | ' + (this.closed ? this.t('yes') : this.t('no')) + ' |
' +
'' + this.t('field_done_ratio') + ': | ' + (this.progress) + '% |
' +
@@ -421,6 +422,7 @@ function PlanningChart(options)
parent_task: 'Parent task',
start_date: 'Start date',
due_date: 'Due date',
+ est_time: 'Estimated time',
description: 'Description',
leaf_task: 'Leaf task',
milestone: 'Milestone',
@@ -1826,6 +1828,7 @@ function PlanningIssue(data)
this.due_date = null;
this.name = data.name;
+ this.estimated_time = data.estimated_time;
this.description = data.description;
this.project = data.project_name;
this.project_identifier = data.project_identifier;
diff --git a/assets/javascripts/planning_old.js b/assets/javascripts/planning_old.js
new file mode 100644
index 0000000..1d9314f
--- /dev/null
+++ b/assets/javascripts/planning_old.js
@@ -0,0 +1,154 @@
+/*
+Copyright 2014 Egbert van der Wal
+
+This file is part of redmine_planning
+
+redmine_planning is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+redmine_planning is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with redmine_planning. If not see .
+*/
+
+function updateDates(el, days)
+{
+ // Make sure to start from the original dates, not from the updated dates
+ var html = el.data('orig_html');
+ if (!html)
+ {
+ html = el.html();
+ el.data('orig_html', html);
+ }
+
+ // Find all date strings
+ var pattern = /([0-9]{2})\/([0-9]{2})\/([0-9]{4})/g;
+ while (match = pattern.exec(html))
+ {
+ var pos = match.index;
+ var len = 10;
+
+ // Parse the date and add the number of days requested
+ var date = new Date(match[3], match[1] - 1, match[2]);
+ date.setDate(parseInt(match[2]) + days);
+
+ // Format into proper date string
+ var newDate = "";
+ if (date.getMonth() < 9)
+ newDate += "0";
+ newDate += (date.getMonth() + 1) + "/";
+ if (date.getDate() < 10)
+ newDate += "0";
+ newDate += date.getDate() + "/" + date.getFullYear();
+
+ // Stitch back together
+ html = html.substr(0, pos) + newDate + html.substr(pos + len);
+ }
+
+ // Replace the entire HTML
+ el.html(html);
+}
+
+$(function () {
+ if ($('.gantt_hdr').length == 0)
+ return;
+
+ // Get the first month header of the Gantt chart
+ var month = $('.gantt_hdr a').first().parent();
+
+ // Get the text of the month: 2014-1 for example
+ var desc = month.children('a').text();
+
+ // Split it into year-month
+ var parts = desc.match(/([0-9]{4})-([0-9]+)/);
+
+ // Unusable
+ if (!parts)
+ return;
+
+ // Extract the two parts
+ var nYear = parts[2];
+ var nMonth = parts[2];
+
+ // Get the number of days in that month/year
+ var nDays = new Date(nYear, nMonth, 0).getDate();
+
+ // Calculate the width of each day
+ var day_width = month.width() / nDays;
+
+ $('div.tooltip').draggable({
+ axis: 'x',
+ grid: [day_width, 0],
+ start: function (event, ui)
+ {
+ var sp = $('#gantt_area').scrollLeft();
+ var task = $(this).prevUntil('.tooltip');
+ task.each(function () {
+ var $t = $(this);
+ $t.data('left', $t.position().left + sp);
+ });
+
+ $(this).data('start_pos', ui.position);
+ },
+ drag: function (event, ui)
+ {
+ var start_pos = $(this).data('start_pos');
+ var diff = ui.position.left - start_pos.left;
+ var task = $(this).prevUntil('.tooltip');
+
+ var days = Math.round(diff / day_width);
+ updateDates($(this), days);
+
+ task.each(function () {
+ var $t = $(this);
+ var l = $t.data('left') + diff;
+ $t.css('left', l + 'px');
+
+ if ($t.hasClass('task_todo'))
+ return false;
+ });
+ },
+ stop: function (event, ui)
+ {
+ var $t = $(this);
+ var start_pos = $t.data('start_pos');
+ var diff = ui.position.left - start_pos.left;
+ var days = Math.round(diff / day_width);
+
+ $t.removeData('start_pos');
+ $t.removeData('orig_html');
+
+ // Acquire Issue ID
+ var url = $(this).find('a.issue').attr('href');
+ url += '/move';
+
+ // Send update to server
+ $.post(url, {days: days, authenticity_token: AUTH_TOKEN},
+ function (response) {
+ response = response[0];
+ if (response.status == "ok")
+ {
+ console.log("Issue moved to " + response.start_date + "-" + response.due_date);
+ }
+ else
+ {
+ alert(response.error);
+ }
+ },
+ "json"
+ )
+ .error(function () {
+ alert('Saving issue failed!');
+ });
+
+ // Update the Gantt chart to show the relations on the updated position
+ drawGanttHandler();
+ }
+ });
+});