Commit f74cc8c9 authored by Eteri's avatar Eteri

erp5_officejs: add link that redirects to related manufacturing order to the gantt lightbox

parent 6e39bbdf
......@@ -30,6 +30,7 @@
// acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
......@@ -44,7 +45,17 @@
console.log("gantt option_dict", option_dict.value);
gadget.renderGantt(); //Launched as service, not blocking
})
return gadget.getUrlFor({
command: 'display',
absolute_url: true
})
.push(function (dialog_url) {
// we used getURlFor to get the whole absolute url, then we hack it
var root_url = dialog_url.split("#")[0];
gadget.property_dict.root_url = root_url;
console.log(root_url);
})
})
.declareJob("renderGantt", function () {
var gadget = this,
option_dict = gadget.property_dict.option_dict;
......@@ -79,6 +90,7 @@
console.log("order_list.length", order_list.length);
for (i = 0; i < order_list.length; i = i + 1) {
order = order_list[i].value;
order.path = order_list[i].id;
order.gantt_color = "rgb(208, 72, 72)";
empty_causality_delivery_list.push(order);
}
......@@ -107,6 +119,7 @@
delivery_list = delivery_list.data.rows;
for (i = 0; i < delivery_list.length; i = i + 1) {
delivery = delivery_list[i].value;
delivery.path = delivery_list[i].id;
delivery.gantt_color = "#3db9d3";
console.log("delivery.causality_uid", delivery.causality_uid);
if ((delivery.causality_uid || 0) > 0) {
......@@ -143,7 +156,9 @@
initial_delivery_list = delivery_list.data.rows;
delivery_list = [];
for (i = 0; i < initial_delivery_list.length; i = i + 1) {
initial_delivery_list[i].value.path = initial_delivery_list[i].id;
delivery_list.push(initial_delivery_list[i].value);
}
for (i = 0; i < gadget.property_dict.empty_causality_delivery_list.length; i = i + 1) {
console.log("pushing empty causality delivery", gadget.property_dict.empty_causality_delivery_list[i]);
......@@ -159,7 +174,8 @@
'stop_date': new Date(delivery.stop_date),
'title': delivery.causality_title,
'type': 'project',
'id': delivery.causality_uid};
'id': delivery.causality_uid,
'path': gadget.property_dict.root_url + delivery.path };
causality_data.start_date = new Date(Math.min.apply(
null, [causality_data.start_date, new Date(delivery.start_date)]));
causality_data.stop_date = new Date(Math.max.apply(
......@@ -175,7 +191,9 @@
'id': delivery.uid,
'start_date': delivery.start_date,
'stop_date': delivery.stop_date,
'background_color': delivery.gantt_color};
'background_color': delivery.gantt_color,
'path': gadget.property_dict.root_url + delivery.path};
if (delivery.causality_uid !== undefined) {
delivery_data.parent_id = delivery.causality_uid;
}
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superseb</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.54927.26212.30361</string> </value>
<value> <string>1008.50670.60071.10939</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1512117612.4</float>
<float>1685525353.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -42,6 +42,7 @@
data = data_list[i];
task.id = data.id;
task.text = data.title;
task.path = data.path.replace("web_site_module/renderjs_runner/", ""); // for now redirect to old UI
// Be Careful, DHTMLX seems less and less open source, and nice features when we
// have a type "project" is unfortunately available only with paid license. Though
// We will still use it to set a different color for this kind of task
......@@ -186,6 +187,27 @@
}
}
// Extend the existing lightbox configuration
var extendedSections = gantt.config.lightbox.sections.slice(); // Copy the existing sections
// Add the custom link section with a label
var linkSection = {
name: "link_section",
height: 30,
map_to: "path",
type: "template" // Use the "template" type for the link section
};
extendedSections.push(linkSection);
gantt.locale.labels.section_link_section = "Manufacturing Execution";
gantt.attachEvent("onBeforeLightbox", function(id) {
var task = gantt.getTask(id);
task.path = "<span id='path'>Jump to </span>" + '<a href="'+task.path + '" target="_blank">related manufacturing execution</a>';
return true;
});
gantt.config.lightbox.sections = extendedSections;
// Interaction when a box is moved. Only for demo purpose, we might
// later find some ways to save changes
gantt.attachEvent("onAfterTaskDrag", function (id, mode) {
......@@ -202,9 +224,8 @@
});
gantt.parse(gantt_configuration.data);
});
}(window, rJS, RSVP, gantt));
\ No newline at end of file
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superseb</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.40847.2383.45909</string> </value>
<value> <string>1008.50679.60785.62600</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,8 +264,8 @@
</tuple>
<state>
<tuple>
<float>1511357707.47</float>
<string>GMT+1</string>
<float>1685525515.89</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
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