Commit e621de78 authored by Sebastien Robin's avatar Sebastien Robin

project: add Gantt diagram on projects (accessible in new interface)

parent 8b78c1a7
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Widget Timeline with Vis</title>
<!-- interfaces -->
<link rel="http://www.renderjs.org/rel/interface" href="gadget_officejs_interface_widget_gantt.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_project_gantt.js" type="text/javascript"></script>
</head>
<body>
<div class="gantt-content">
</div>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, console */
/*jslint nomen: true, indent: 2 */
(function (window, rJS, RSVP) {
"use strict";
/////////////////////////////////////////////////////////////////
// templates
/////////////////////////////////////////////////////////////////
var gadget_klass = rJS(window);
/////////////////////////////////////////////////////////////////
// some methods
/////////////////////////////////////////////////////////////////
gadget_klass
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
.ready(function (gadget) {
gadget.property_dict = {};
})
/////////////////////////////////////////////////////////////////
// published methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('render', function (option_dict) {
var gadget = this,
container,
graph_data_and_parameter,
chart;
gadget.property_dict.option_dict = option_dict.value;
console.log("gantt option_dict", option_dict.value);
gadget.renderGantt(); //Launched as service, not blocking
})
.declareJob("renderGantt", function () {
var gadget = this,
option_dict = gadget.property_dict.option_dict;
return gadget.declareGadget(
"unsafe/gadget_officejs_widget_gantt_dhtmlx.html",
{scope: "gantt",
sandbox: "iframe",
element: gadget.element.querySelector(".gantt-content")
})
.push(function (gantt_widget) {
// First search all project lines
var query;
gadget.property_dict.gantt_widget = gantt_widget;
console.log("gantt_widget", gantt_widget);
query = 'portal_type: ="Project Line" AND relative_url: "' + option_dict.project_relative_url + '/%"';
console.log("going to query catalog for project_line", query);
return gadget.jio_allDocs({
query: query,
limit: 10000,
sort_on: [['creation_date', 'ascending']],
select_list: ['reference', 'title', 'start_date', 'stop_date', 'uid']
});
})
.push(function (project_line_list) {
// Then find all task and task reports related to it
var source_project_uid_list = [0], // Initiliaze with 0 to make sure to have at least one uid to search for
i, project_line, query,
now = new Date();
project_line_list = project_line_list.data.rows;
for (i = 0; i < project_line_list.length; i = i + 1) {
project_line = project_line_list[i].value;
if (project_line.stop_date === undefined || (new Date(project_line.stop_date) > now)) {
if (source_project_uid_list.indexOf(source_project_uid_list.uid) === -1) {
source_project_uid_list.push(project_line.uid);
}
}
}
query = '((portal_type: = "Task" AND NOT simulation_state: ("cancelled", "deleted", "confirmed")) OR (portal_type: ="Task Report" AND NOT simulation_state: ("cancelled", "deleted"))) AND source_project_uid: (' + source_project_uid_list.join(', ') + ')';
console.log("QUERY", query);
return gadget.jio_allDocs({
query: query,
limit: 10000,
sort_on: [['delivery.start_date', 'ascending']],
select_list: ['reference', 'title', 'start_date', 'stop_date', 'uid', 'source_project_uid', 'source_project_title']
});
})
.push(function (task_list) {
var i, task, source_project_uid_list = [],
source_project_dict = {}, source_project_data,
gantt_data = {},
tree_list = [],
data_list = [],
sale_order_uid,
delivery_data, tree_data;
task_list = task_list.data.rows;
console.log("task_list", task_list);
for (i = 0; i < task_list.length; i = i + 1) {
task = task_list[i].value;
if (task.source_project_uid !== undefined) {
if (source_project_uid_list.indexOf(task.source_project_uid) === -1) {
source_project_uid_list.push(task.source_project_uid);
}
source_project_data = source_project_dict[task.source_project_uid] || {'start_date': new Date(task.start_date),
'stop_date': new Date(task.stop_date),
'title': task.source_project_title,
'type': 'project',
'id': task.source_project_uid};
source_project_data.start_date = new Date(Math.min.apply(
null, [source_project_data.start_date, new Date(task.start_date)]));
source_project_data.stop_date = new Date(Math.max.apply(
null, [source_project_data.stop_date, new Date(task.stop_date)]));
source_project_dict[task.source_project_uid] = source_project_data;
}
if (i === 0) {
// We assume that by the sort on order_reference that the first line is a level 1 line
sale_order_uid = task.parent_uid;
}
if (task.start_date !== undefined && task.stop_date !== undefined) {
delivery_data = {'title': task.title,
'id': task.uid,
'tree_id': task.uid,
'parent_id': task.source_project_uid,
'start_date': task.start_date,
'stop_date': task.stop_date};
if (task.parent_uid !== sale_order_uid) {
delivery_data.parent_id = task.parent_uid;
}
data_list.push(delivery_data);
}
}
for (i = 0; i < source_project_uid_list.length; i = i + 1) {
source_project_data = source_project_dict[source_project_uid_list[i]];
data_list.push(source_project_data);
}
gantt_data.data_list = data_list;
console.log("gantt_data", gantt_data);
return gadget.property_dict.gantt_widget.render(gantt_data);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>project_view_gantt</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Project Gantt</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Project_viewGantt</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>project_gantt</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Project_viewGantt</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Project_viewGantt</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gantt</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>gadget_url</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>project_gantt</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_gadget_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Project Gantt</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: {"project_relative_url":here.getRelativeUrl(),}</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:\'gadget_officejs_project_gantt.html\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -32,6 +32,7 @@ Project | milestone
Project | planning
Project | project_monthly_report
Project | project_task_report
Project | project_view_gantt
Project | report
Project | task_fast_input_dialog
Project | task_list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment