...
 
Commits (6)
......@@ -67,11 +67,11 @@
<h1>Dream Simulation</h1>
<div data-role="controlgroup" data-type="horizontal" class="ui-btn-right">
<a data-icon="forward"
class="next_step_link ui-btn ui-icon-forward ui-btn-icon-right">Continue</a>
<!-- Next button to cycle through the results, similar to ERP5 navigation -->
<a data-icon="forward"
style="display: none"
style="display: none"
class="next_link ui-btn ui-icon-forward ui-btn-icon-right">Next</a>
</div>
......
......@@ -123,6 +123,26 @@
return gadget.aq_pleasePublishMyState(forward_kw);
});
}
function getNextStepLink(gadget, portal_type, options) {
// We define `next_step_action` in the json
if (options.action_definition.next_step_action !== undefined) {
var forward_kw = {
action: options.action_definition.next_step_action,
id: options.id
};
return gadget.aq_pleasePublishMyState(forward_kw);
}
// in the first POC, we had this hardcoded
if (options.action === "view_machine_shift_spreadsheet") {
var forward_kw = {
action: "view_run_simulation",
id: options.id
};
return gadget.aq_pleasePublishMyState(forward_kw);
}
return false;
}
function getTitle(gadget, portal_type, options) {
var title;
......@@ -453,7 +473,8 @@
calculateNavigationHTML(gadget, portal_type, options),
gadget.aq_pleasePublishMyState(back_kw),
getTitle(gadget, portal_type, options),
getNextLink(gadget, portal_type, options)
getNextLink(gadget, portal_type, options),
getNextStepLink(gadget, portal_type, options)
]);
}).push(function (result_list) {
var nav_html = result_list[1],
......@@ -471,7 +492,6 @@
// Update forward link
gadget.props.element
.getElementsByClassName("next_link")[0].href = result_list[4];
// Update the navigation panel
// Clear the previous rendering
while (nav_element.firstChild) {
......@@ -491,6 +511,28 @@
element.appendChild(page_element);
$(element).trigger('create');
return result_list[5];
}).push(function (next_step_link) {
var button = gadget.props.element
.getElementsByClassName("next_step_link")[0];
$(button).hide();
var idle_timer;
function resetTimer() {
clearTimeout(idle_timer);
idle_timer = setTimeout(function () { $(button).show() },
idle_seconds*1); // XXX show immediatly
}
if (next_step_link !== false) {
button.href = next_step_link;
var idle_seconds = 10;
$(document.body).on('keydown click', resetTimer);
resetTimer();
}
else {
$(document.body).off('keydown click', resetTimer);
}
// XXX RenderJS hack to start sub gadget services
// Only work if this gadget has no parent.
if (page_gadget.startService !== undefined) {
......
......@@ -145,6 +145,7 @@
edge_data.destination = getNodeId(gadget, connection.targetId);
gadget.props.data.graph.edge[connection.id] = edge_data;
}
checkNodeConstraint(gadget,getNodeId(gadget, connection.targetId));
gadget.notifyDataChanged();
}
......@@ -293,6 +294,23 @@
gadget.notifyDataChanged();
}
function checkNodeConstraint(gadget, node_id) {
var element_id = gadget.props.node_id_to_dom_element_id[node_id],
element = $(gadget.props.element).find("#" + element_id),
jsplumb_instance = gadget.props.jsplumb_instance,
node_class = gadget.props.data.graph.node[node_id]._class;
if (jsplumb_instance.getConnections({target:element_id}).length === 0 &&
node_class.toLowerCase().search('source') === -1) {
var warning = $("<div></div>").attr({
"class": "alert_no_input ui-btn-icon-notext ui-icon-alert",
"title": "No input defined!"
});
element.append(warning);
} else {
element.find(".alert_no_input").remove();
}
}
function updateElementData(gadget, node_id, data) {
var element_id = gadget.props.node_id_to_dom_element_id[node_id],
......@@ -900,6 +918,9 @@
$.each(this.props.data.graph.edge, function (key, value) {
addEdge(gadget, key, value);
});
$.each(this.props.data.graph.node, function (key, value) {
checkNodeConstraint(gadget, key);
});
return RSVP.all([
waitForDrop(gadget),
......
......@@ -67,11 +67,11 @@
<h1>Dream Simulation</h1>
<div data-role="controlgroup" data-type="horizontal" class="ui-btn-right">
<a data-icon="forward"
class="next_step_link ui-btn ui-icon-forward ui-btn-icon-right">Continue</a>
<!-- Next button to cycle through the results, similar to ERP5 navigation -->
<a data-icon="forward"
style="display: none"
style="display: none"
class="next_link ui-btn ui-icon-forward ui-btn-icon-right">Next</a>
</div>
......
......@@ -103,6 +103,25 @@
return gadget.aq_pleasePublishMyState(forward_kw);
});
}
function getNextStepLink(gadget, portal_type, options) {
// We define `next_step_action` in the json
if (options.action_definition.next_step_action !== undefined) {
var forward_kw = {
action: options.action_definition.next_step_action,
id: options.id
};
return gadget.aq_pleasePublishMyState(forward_kw);
}
// in the first POC, we had this hardcoded
if (options.action === "view_machine_shift_spreadsheet") {
var forward_kw = {
action: "view_run_simulation",
id: options.id
};
return gadget.aq_pleasePublishMyState(forward_kw);
}
return false;
}
function getTitle(gadget, portal_type, options) {
var title;
if (portal_type === "Input Module") {
......@@ -330,7 +349,7 @@
return page_gadget.render(options);
}
}).push(function() {
return RSVP.all([ page_gadget.getElement(), calculateNavigationHTML(gadget, portal_type, options), gadget.aq_pleasePublishMyState(back_kw), getTitle(gadget, portal_type, options), getNextLink(gadget, portal_type, options) ]);
return RSVP.all([ page_gadget.getElement(), calculateNavigationHTML(gadget, portal_type, options), gadget.aq_pleasePublishMyState(back_kw), getTitle(gadget, portal_type, options), getNextLink(gadget, portal_type, options), getNextStepLink(gadget, portal_type, options) ]);
}).push(function(result_list) {
var nav_html = result_list[1], page_element = result_list[0];
// Update title
......@@ -358,6 +377,25 @@
}
element.appendChild(page_element);
$(element).trigger("create");
return result_list[5];
}).push(function(next_step_link) {
var button = gadget.props.element.getElementsByClassName("next_step_link")[0];
$(button).hide();
var idle_timer;
function resetTimer() {
clearTimeout(idle_timer);
idle_timer = setTimeout(function() {
$(button).show();
}, idle_seconds * 1);
}
if (next_step_link !== false) {
button.href = next_step_link;
var idle_seconds = 10;
$(document.body).on("keydown click", resetTimer);
resetTimer();
} else {
$(document.body).off("keydown click", resetTimer);
}
// XXX RenderJS hack to start sub gadget services
// Only work if this gadget has no parent.
if (page_gadget.startService !== undefined) {
......
......@@ -117,6 +117,7 @@
edge_data.destination = getNodeId(gadget, connection.targetId);
gadget.props.data.graph.edge[connection.id] = edge_data;
}
checkNodeConstraint(gadget, getNodeId(gadget, connection.targetId));
gadget.notifyDataChanged();
}
function convertToAbsolutePosition(gadget, x, y) {
......@@ -217,6 +218,20 @@
});
gadget.notifyDataChanged();
}
function checkNodeConstraint(gadget, node_id) {
var element_id = gadget.props.node_id_to_dom_element_id[node_id], element = $(gadget.props.element).find("#" + element_id), jsplumb_instance = gadget.props.jsplumb_instance, node_class = gadget.props.data.graph.node[node_id]._class;
if (jsplumb_instance.getConnections({
target: element_id
}).length === 0 && node_class.toLowerCase().search("source") === -1) {
var warning = $("<div></div>").attr({
"class": "alert_no_input ui-btn-icon-notext ui-icon-alert",
title: "No input defined!"
});
element.append(warning);
} else {
element.find(".alert_no_input").remove();
}
}
function updateElementData(gadget, node_id, data) {
var element_id = gadget.props.node_id_to_dom_element_id[node_id], new_id = data.id;
$(gadget.props.element).find("#" + element_id).text(data.data.name || new_id).attr("title", data.data.name || new_id).append('<div class="ep"></div></div>');
......@@ -638,6 +653,9 @@
$.each(this.props.data.graph.edge, function(key, value) {
addEdge(gadget, key, value);
});
$.each(this.props.data.graph.node, function(key, value) {
checkNodeConstraint(gadget, key);
});
return RSVP.all([ waitForDrop(gadget), waitForConnection(gadget), waitForConnectionDetached(gadget), waitForConnectionClick(gadget), gadget.props.nodes_click_monitor ]);
});
})(RSVP, rJS, $, jsPlumb, Handlebars, loopEventListener, promiseEventListener, DOMParser);
\ No newline at end of file
/*!
* QUnit 1.17.1
* QUnit 1.18.0
* http://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-01-20T19:39Z
* Date: 2015-04-03T10:23Z
*/
/** Font Family and Sizes */
......@@ -116,7 +116,13 @@
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
display: none;
visibility: hidden;
position: absolute;
width: 0px;
height: 0px;
padding: 0;
border: 0;
margin: 0;
}
#qunit-tests li strong {
......@@ -132,6 +138,11 @@
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li p a {
padding: 0.25em;
color: #6B6464;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
......
This diff is collapsed.
CACHE MANIFEST
# This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator
# Time: Wed Sep 16 2015 18:23:50 GMT+0200 (CEST)
# Time: Fri Oct 14 2016 11:33:31 GMT+0200 (CEST)
CACHE:
daff/index.html
......