Commit 07a0d43d authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Allow to loop on results.

parent 27c9ec71
...@@ -47,12 +47,21 @@ ...@@ -47,12 +47,21 @@
</div> </div>
<header data-role="header"> <header data-role="header">
<a href="#leftpanel"
data-icon="bars" <div data-role="controlgroup" data-type="horizontal" class="ui-btn-left">
class="menu_link ui-btn ui-icon-bars ui-btn-icon-left">Menu</a> <a href="#leftpanel"
<a data-icon="back" data-icon="bars"
class="back_link ui-btn ui-icon-back ui-btn-icon-left">Back</a> class="menu_link ui-btn ui-icon-bars ui-btn-icon-left">Menu</a>
<a data-icon="back"
class="back_link ui-btn ui-icon-back ui-btn-icon-right">Back</a>
</div>
<h1>Dream Simulation</h1> <h1>Dream Simulation</h1>
<div data-role="controlgroup" data-type="horizontal" class="ui-btn-right">
<a data-icon="forward"
class="next_link ui-btn ui-icon-forward ui-btn-icon-right">Next</a>
</div>
</header> </header>
<div class="nav_container"></div> <div class="nav_container"></div>
......
...@@ -118,6 +118,40 @@ ...@@ -118,6 +118,40 @@
}); });
} }
function getNextLink(gadget, portal_type, options) {
var forward_kw = {action: options.action || "view"},
queue = new RSVP.Queue();
if (portal_type === "Input") {
forward_kw.id = options.id;
} else if (portal_type === "Output") {
forward_kw.id = options.id;
queue
.push(function () {
return gadget.getDeclaredGadget("jio");
})
.push(function (jio_gadget) {
return jio_gadget.getAttachment({
_id: options.id,
"_attachment": "simulation.json"
});
})
.push(function (sim_json) {
var document_list = JSON.parse(sim_json),
current = parseInt(options.result, 10);
if (current === (document_list.length - 1)) {
forward_kw.result = 0;
} else {
forward_kw.result = current + 1;
}
});
} else if (portal_type !== "Input Module") {
throw new Error("Unknown portal type: " + portal_type);
}
return queue.push(function () {
return gadget.aq_pleasePublishMyState(forward_kw);
});
}
function getTitle(gadget, portal_type, options) { function getTitle(gadget, portal_type, options) {
var title; var title;
if (portal_type === "Input Module") { if (portal_type === "Input Module") {
...@@ -377,7 +411,8 @@ ...@@ -377,7 +411,8 @@
page_gadget.getElement(), page_gadget.getElement(),
calculateNavigationHTML(gadget, portal_type, options), calculateNavigationHTML(gadget, portal_type, options),
gadget.aq_pleasePublishMyState(back_kw), gadget.aq_pleasePublishMyState(back_kw),
getTitle(gadget, portal_type, options) getTitle(gadget, portal_type, options),
getNextLink(gadget, portal_type, options)
]); ]);
}).push(function (result_list) { }).push(function (result_list) {
var nav_html = result_list[1], var nav_html = result_list[1],
...@@ -391,6 +426,10 @@ ...@@ -391,6 +426,10 @@
// Update back link // Update back link
gadget.props.element gadget.props.element
.getElementsByClassName("back_link")[0].href = result_list[2]; .getElementsByClassName("back_link")[0].href = result_list[2];
// XXX Hide the forward button in case of non result?
// Update forward link
gadget.props.element
.getElementsByClassName("next_link")[0].href = result_list[4];
// Update the navigation panel // Update the navigation panel
// Clear the previous rendering // Clear the previous rendering
......
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