Commit 844ef6b1 authored by Roque's avatar Roque Committed by Roque

erp5_officejs: improvements in gantt chart (for project management)

parent 368c2a37
.ui-icon-spinner {
opacity: 1;
}
.ui-icon-spinner::before {
content: "\f110";
animation: spin 0.5s infinite linear;
}
.first-loader {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 300%;
animation-name: fadein;
animation-duration: 0.2s;
animation-delay: 0.3s;
animation-fill-mode: both;
animation-timing-function: ease-in;
}
.gadget-content .field_container > div > div > div.ui-field-contain div.spinner {
width: 0%;
}
.gadget-content .field_container > div > div > div.ui-field-contain div.hidden {
visibility: hidden;
}
.gadget-gantt .ui-hidden {
visibility: hidden;
}
\ No newline at end of file
...@@ -14,10 +14,17 @@ ...@@ -14,10 +14,17 @@
<!-- custom script --> <!-- custom script -->
<script src="gadget_officejs_project_gantt.js" type="text/javascript"></script> <script src="gadget_officejs_project_gantt.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="gadget_officejs_project_gantt.css">
</head> </head>
<body> <body>
<div class="gantt-content"> <div class="gadget-gantt">
<div id="gantt_spinner" class="ui-icon-spinner ui-btn-icon-notext first-loader spinner"></div>
<div class="empty-gantt ui-hidden">
<span>There are no tasks for this project</span>
</div>
<div class="gantt-content ui-hidden">
</div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -160,11 +160,13 @@ ...@@ -160,11 +160,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -208,16 +210,20 @@ ...@@ -208,16 +210,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -226,7 +232,7 @@ ...@@ -226,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>superseb</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -240,7 +246,7 @@ ...@@ -240,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.40716.45672.25429</string> </value> <value> <string>980.38723.24484.50073</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,8 +264,8 @@ ...@@ -258,8 +264,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1511352530.83</float> <float>1577107598.2</float>
<string>GMT+1</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
...@@ -267,16 +273,20 @@ ...@@ -267,16 +273,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -324,7 +334,9 @@ ...@@ -324,7 +334,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
/*global window, rJS, RSVP, console */ /*global window, rJS, RSVP, document, console */
/*jslint nomen: true, indent: 2 */ /*jslint nomen: true, indent: 2 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, document) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
}) })
.declareJob("renderGantt", function () { .declareJob("renderGantt", function () {
var gadget = this, var gadget = this,
empty_gantt_element = gadget.element.querySelector(".empty-gantt"),
option_dict = gadget.property_dict.option_dict; option_dict = gadget.property_dict.option_dict;
return gadget.declareGadget( return gadget.declareGadget(
"unsafe/gadget_officejs_widget_gantt_dhtmlx.html", "unsafe/gadget_officejs_widget_gantt_dhtmlx.html",
...@@ -99,22 +100,31 @@ ...@@ -99,22 +100,31 @@
tree_list = [], tree_list = [],
data_list = [], data_list = [],
sale_order_uid, sale_order_uid,
delivery_data, tree_data; delivery_data, tree_data, start_date,
gantt_spinner = document.getElementById("gantt_spinner"),
now = new Date();
task_list = task_list.data.rows; task_list = task_list.data.rows;
console.log("task_list", task_list); console.log("task_list:", task_list);
if (task_list.length) {
gadget.element.querySelector(".gantt-content").classList.remove("ui-hidden");
for (i = 0; i < task_list.length; i = i + 1) { for (i = 0; i < task_list.length; i = i + 1) {
task = task_list[i].value; task = task_list[i].value;
if (task.source_project_uid !== undefined) { if (task.source_project_uid !== undefined) {
if (source_project_uid_list.indexOf(task.source_project_uid) === -1) { if (source_project_uid_list.indexOf(task.source_project_uid) === -1) {
source_project_uid_list.push(task.source_project_uid); 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), if (!task.start_date) {
start_date = new Date();
} else {
start_date = task.start_date;
}
source_project_data = source_project_dict[task.source_project_uid] || {'start_date': new Date(start_date),
'stop_date': new Date(task.stop_date), 'stop_date': new Date(task.stop_date),
'title': task.source_project_title, 'title': task.source_project_title,
'type': 'project', 'type': 'project',
'id': task.source_project_uid}; 'id': task.source_project_uid};
source_project_data.start_date = new Date(Math.min.apply( source_project_data.start_date = new Date(Math.min.apply(
null, [source_project_data.start_date, new Date(task.start_date)])); null, [source_project_data.start_date, new Date(start_date)]));
source_project_data.stop_date = new Date(Math.max.apply( source_project_data.stop_date = new Date(Math.max.apply(
null, [source_project_data.stop_date, new Date(task.stop_date)])); null, [source_project_data.stop_date, new Date(task.stop_date)]));
source_project_dict[task.source_project_uid] = source_project_data; source_project_dict[task.source_project_uid] = source_project_data;
...@@ -123,7 +133,7 @@ ...@@ -123,7 +133,7 @@
// We assume that by the sort on order_reference that the first line is a level 1 line // We assume that by the sort on order_reference that the first line is a level 1 line
sale_order_uid = task.parent_uid; sale_order_uid = task.parent_uid;
} }
if (task.start_date !== undefined && task.stop_date !== undefined) { if (task.start_date && task.stop_date) {
delivery_data = {'title': task.title, delivery_data = {'title': task.title,
'id': task.uid, 'id': task.uid,
'tree_id': task.uid, 'tree_id': task.uid,
...@@ -142,11 +152,14 @@ ...@@ -142,11 +152,14 @@
} }
gantt_data.data_list = data_list; gantt_data.data_list = data_list;
console.log("gantt_data", gantt_data); gantt_spinner.classList.add("hidden");
return gadget.property_dict.gantt_widget.render(gantt_data); return gadget.property_dict.gantt_widget.render(gantt_data);
} else {
gantt_spinner.classList.add("hidden");
empty_gantt_element.classList.remove("ui-hidden");
}
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, document));
\ No newline at end of file \ No newline at end of file
...@@ -160,11 +160,13 @@ ...@@ -160,11 +160,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -208,16 +210,20 @@ ...@@ -208,16 +210,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -226,7 +232,7 @@ ...@@ -226,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>superseb</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -240,7 +246,7 @@ ...@@ -240,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.40841.16928.9318</string> </value> <value> <string>980.38728.1170.38161</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,8 +264,8 @@ ...@@ -258,8 +264,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1511357651.94</float> <float>1576781323.89</float>
<string>GMT+1</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
...@@ -267,16 +273,20 @@ ...@@ -267,16 +273,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -324,7 +334,9 @@ ...@@ -324,7 +334,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
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