Commit 2ae6d546 authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Move global menu into context dependent tabs.

Provides a more dynamic navigation.
Allow to display all simulation results.
parent a9df9243
......@@ -21,8 +21,6 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("aq_allDocs", "allDocs")
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
.declareAcquiredMethod("whoWantToDisplayThisPage",
"whoWantToDisplayThisPage")
.declareAcquiredMethod("whoWantToDisplayThisDocument",
"whoWantToDisplayThisDocument")
......@@ -33,9 +31,7 @@
var gadget = this;
return gadget.aq_allDocs({"select_list": ["title", "modified"]})
.push(function (document_list) {
var result_list = [gadget.whoWantToDisplayThisPage(
"InputModule_viewAddDocumentDialog"
)],
var result_list = [],
doc,
i;
for (i = 0; i < document_list.data.total_rows; i += 1) {
......@@ -50,16 +46,23 @@
})
.push(function (document_list) {
// Create new doc if nothing exists
if (document_list.length === 1) {
return gadget.pleaseRedirectMyHash(document_list[0]);
if (document_list.length === 0) {
return gadget
.whoWantToDisplayThisDocument(
undefined,
"view_fast_input"
)
.push(function (url) {
return gadget.pleaseRedirectMyHash(url);
});
}
var i,
parameter_list = [],
doc;
for (i = 1; i < document_list.length; i += 1) {
for (i = 0; i < document_list.length; i += 1) {
doc = document_list[i];
parameter_list[i - 1] = {
parameter_list[i] = {
link: doc[0],
title: doc[1] + " (" + doc[2] + ")"
};
......@@ -72,12 +75,5 @@
documentlist: parameter_list
});
});
})
.declareMethod("getNavigationList", function () {
return this.whoWantToDisplayThisPage("InputModule_viewAddDocumentDialog")
.push(function (url) {
return [{title: "New Document", link: url}];
});
});
}(window, rJS, RSVP, Handlebars, initGadgetMixin));
......@@ -11,7 +11,6 @@
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewDocumentManagement.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery,
/*global console, rJS, RSVP, jQuery,
promiseEventListener, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, $, promiseEventListener,
(function (window, rJS, RSVP, $, promiseEventListener,
initGadgetMixin) {
"use strict";
......@@ -104,7 +104,6 @@
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -153,5 +152,5 @@
waitForKnowledgeExtraction(this)
]);
});
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, promiseEventListener,
}(window, rJS, RSVP, jQuery, promiseEventListener,
initGadgetMixin));
......@@ -7,7 +7,6 @@
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewProductionLine.js" type="text/javascript"></script>
</head>
<body>
......
/*global window, rJS, RSVP, initDocumentPageMixin */
(function (window, rJS, RSVP, initDocumentPageMixin) {
/*global window, rJS, RSVP */
(function (window, rJS, RSVP) {
"use strict";
var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
gadget_klass
.ready(function (g) {
......@@ -41,4 +40,4 @@
return productionline.startService();
});
});
}(window, rJS, RSVP, initDocumentPageMixin));
}(window, rJS, RSVP));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Result List</title>
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.handlebars.relative_dest %>" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<ul data-role="listview" data-inset="true" class="document-listview">
{{#documentlist}}
<li><a href="{{link}}">{{title}}</a></li>
{{/documentlist}}
</ul>
</script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewResultList.js" type="text/javascript"></script>
</head>
<body>
<section class="document_list"></section>
</body>
</html>
/*global console, rJS, RSVP, Handlebars, initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
source = gadget_klass.__template_element
.getElementById("table-template")
.innerHTML,
table_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("whoWantToDisplayThisResult",
"whoWantToDisplayThisResult")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this;
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "simulation.json"
})
.push(function (sim_json) {
var document_list = JSON.parse(sim_json),
result_list = [],
i;
for (i = 0; i < document_list.length; i += 1) {
result_list.push(RSVP.all([
gadget.whoWantToDisplayThisResult(gadget.props.jio_key, i),
document_list[i].score,
document_list[i].key
]));
}
return RSVP.all(result_list);
})
.push(function (document_list) {
var i,
parameter_list = [],
doc;
for (i = 0; i < document_list.length; i += 1) {
doc = document_list[i];
parameter_list[i] = {
link: doc[0],
title: doc[1] + " " + doc[2]
};
}
gadget.props.element.querySelector('.document_list').innerHTML =
table_template({
documentlist: parameter_list
});
});
});
}(window, rJS, RSVP, Handlebars, initGadgetMixin));
......@@ -16,7 +16,6 @@
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewSimulation.js" type="text/javascript"></script>
</head>
<body>
......
/*global rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars,
/*global rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, $, Handlebars,
(function (window, rJS, RSVP, $, Handlebars,
promiseEventListener, initGadgetMixin) {
"use strict";
......@@ -16,7 +16,6 @@
label_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -24,9 +23,10 @@
.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("aq_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("aq_ajax", "jio_ajax")
.declareAcquiredMethod("aq_getConfigurationDict", "getConfigurationDict")
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
.declareAcquiredMethod("whoWantToDisplayThisDocumentPage",
"whoWantToDisplayThisDocumentPage")
.declareAcquiredMethod("whoWantToDisplayThisDocument",
"whoWantToDisplayThisDocument")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -39,20 +39,10 @@
.querySelector(".simulation_parameters"),
value,
queue,
data,
property_list =
options.configuration_dict['Dream-Configuration'].property_list;
data;
this.props.jio_key = options.id;
queue = gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
})
.push(function (json) {
data = JSON.parse(json).general;
});
function addField(property, value) {
var sub_gadget;
queue
......@@ -80,6 +70,17 @@
});
}
queue = gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
})
.push(function (json) {
data = JSON.parse(json).general;
return gadget.aq_getConfigurationDict();
})
.push(function (configuration_dict) {
var property_list =
configuration_dict['Dream-Configuration'].property_list;
for (i = 0; i < property_list.length; i += 1) {
property = property_list[i];
if (property._class === "Dream.Property") {
......@@ -87,6 +88,7 @@
addField(property, value);
}
}
});
return queue;
})
......@@ -142,14 +144,14 @@
});
})
.push(function (result) {
return gadget.whoWantToDisplayThisDocumentPage(
"Output_viewDebugJson",
gadget.props.jio_key
return gadget.whoWantToDisplayThisDocument(
gadget.props.jio_key,
"view_result"
);
})
.push(function (url) {
return gadget.pleaseRedirectMyHash(url);
});
});
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars,
}(window, rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin));
......@@ -8,7 +8,6 @@
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewTable.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin) {
/*global console, rJS, RSVP, initGadgetMixin */
(function (window, rJS, RSVP, initGadgetMixin) {
"use strict";
var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
initGadgetMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
......@@ -42,4 +41,4 @@
return tableeditor.startService();
});
});
}(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin));
}(window, rJS, RSVP, initGadgetMixin));
......@@ -7,7 +7,6 @@
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewDebugJson.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin) {
/*global console, rJS, RSVP, initGadgetMixin */
(function (window, rJS, RSVP, initGadgetMixin) {
"use strict";
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -17,28 +16,20 @@
.declareMethod("render", function (options) {
var gadget = this;
this.props.jio_key = options.id;
this.props.result = options.result;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
}),
gadget.aq_getAttachment({
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "simulation.json"
})
]);
})
.push(function (result_list) {
.push(function (result_json) {
var result = JSON.parse(result_json);
gadget.props.element.querySelector(".json_input").textContent =
result_list[0];
// XXX Hardcoded result
JSON.stringify(result[gadget.props.result].input);
gadget.props.element.querySelector(".json_output").textContent =
JSON.stringify(JSON.parse(result_list[1])[0].result);
JSON.stringify(result[gadget.props.result].result);
});
});
}(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin));
}(window, rJS, RSVP, initGadgetMixin));
......@@ -8,7 +8,6 @@
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.handlebars.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewExitStatistics.js" type="text/javascript"></script>
<script id="interval-through-metric-template" type="text/x-handlebars-template">
......
/*global console, rJS, RSVP, initDocumentPageMixin, Handlebars,
/*global console, rJS, RSVP, Handlebars,
initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, Handlebars,
(function (window, rJS, RSVP, Handlebars,
initGadgetMixin) {
"use strict";
......@@ -125,7 +125,6 @@
}
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -139,6 +138,7 @@
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
......@@ -146,10 +146,9 @@
})
.push(function (simulation_json) {
var result = calculate_exit_stat(
// XXX Hardcoded result
JSON.parse(simulation_json)[0].result
JSON.parse(simulation_json)[gadget.props.result].result
);
gadget.props.element.innerHTML = result;
});
});
}(window, rJS, RSVP, initDocumentPageMixin, Handlebars, initGadgetMixin));
}(window, rJS, RSVP, Handlebars, initGadgetMixin));
......@@ -11,7 +11,6 @@
<script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.dhtmlxganttjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewJobGantt.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, gantt,
/*global console, rJS, RSVP, jQuery, gantt,
initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, $, gantt,
(function (window, rJS, RSVP, $, gantt,
initGadgetMixin) {
"use strict";
......@@ -203,7 +203,6 @@
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -217,6 +216,7 @@
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
......@@ -224,8 +224,7 @@
})
.push(function (simulation_json) {
gadget.props.result = job_gantt_widget(
// XXX Hardcoded result
JSON.parse(simulation_json)[0]
JSON.parse(simulation_json)[gadget.props.result]
);
});
})
......@@ -258,4 +257,4 @@
throw error;
});
});
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, gantt, initGadgetMixin));
}(window, rJS, RSVP, jQuery, gantt, initGadgetMixin));
......@@ -9,7 +9,6 @@
<script src="../<%= curl.momentjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewJobScheduleSpreadsheet.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin */
/*global console, rJS, RSVP, moment, initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin) {
(function (window, rJS, RSVP, moment, initGadgetMixin) {
"use strict";
function job_schedule_spreadsheet_widget(all_data) {
......@@ -150,7 +150,6 @@
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
......@@ -165,6 +164,7 @@
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return new RSVP.Queue()
.push(function () {
......@@ -180,8 +180,7 @@
return result_list[1].render(
JSON.stringify(
job_schedule_spreadsheet_widget(
// XXX Hardcoded result
JSON.parse(result_list[0])[0]
JSON.parse(result_list[0])[gadget.props.result]
)
)
);
......@@ -206,4 +205,4 @@
return tableeditor.startService();
});
});
}(window, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin));
}(window, rJS, RSVP, moment, initGadgetMixin));
......@@ -9,7 +9,6 @@
<script src="../<%= curl.jqueryflot.relative_dest %>"></script>
<script src="../<%= curl.jqueryflotstack.relative_dest %>"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewQueueStatGraph.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin */
/*global console, rJS, RSVP, jQuery, initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, $, initGadgetMixin) {
(function (window, rJS, RSVP, $, initGadgetMixin) {
"use strict";
function queue_stat_widget(output_data) {
......@@ -19,7 +19,6 @@
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -33,6 +32,7 @@
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
......@@ -40,8 +40,7 @@
})
.push(function (simulation_json) {
gadget.props.series = queue_stat_widget(
// XXX Hardcoded result
JSON.parse(simulation_json)[0].result
JSON.parse(simulation_json)[gadget.props.result].result
);
});
})
......@@ -53,4 +52,4 @@
this.props.series
);
});
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin));
}(window, rJS, RSVP, jQuery, initGadgetMixin));
......@@ -10,7 +10,6 @@
<script src="../<%= curl.jqueryflot.relative_dest %>"></script>
<script src="../<%= curl.jqueryflotstack.relative_dest %>"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewStationUtilisationGraph.js" type="text/javascript"></script>
</head>
<body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, $, initGadgetMixin) {
/*global console, rJS, RSVP, jQuery, initGadgetMixin */
(function (window, rJS, RSVP, $, initGadgetMixin) {
"use strict";
function station_utilisation_graph_widget(output_data) {
......@@ -124,7 +124,6 @@
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -138,6 +137,7 @@
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
......@@ -145,8 +145,7 @@
})
.push(function (simulation_json) {
gadget.props.result_list = station_utilisation_graph_widget(
// XXX Hardcoded result
JSON.parse(simulation_json)[0].result
JSON.parse(simulation_json)[gadget.props.result].result
);
});
})
......@@ -159,4 +158,4 @@
this.props.result_list[1]
);
});
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin));
}(window, rJS, RSVP, jQuery, initGadgetMixin));
......@@ -16,13 +16,24 @@
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="index.js" type="text/javascript"></script>
<script id="navigation-template" type="text/x-handlebars-template">
<script id="panel-template" type="text/x-handlebars-template">
<ul data-role="listview">
<li><a class="home_link ui-btn ui-icon-home ui-btn-icon-left" data-icon="home">Documents</a></li>
<li><a class="fast_input_link ui-btn ui-icon-plus ui-btn-icon-left" data-icon="plus">New Document</a></li>
{{#navigationlist}}
<li><a href="{{link}}">{{title}}</a></li>
{{/navigationlist}}
</ul>
</script>
<script id="active-navigation-template" type="text/x-handlebars-template">
<li><a class="ui-btn-active ui-state-persist" href="{{link}}">{{title}}</a></li>
</script>
<script id="navigation-template" type="text/x-handlebars-template">
<li><a href="{{link}}">{{title}}</a></li>
</script>
</head>
<body>
......@@ -36,11 +47,14 @@
</div>
<header data-role="header">
<a href="#leftpanel" class="menu_link">Menu</a>
<a href="#leftpanel"
data-icon="bars"
class="menu_link ui-btn ui-icon-bars ui-btn-icon-left">Menu</a>
<h1>Dream Simulation</h1>
<a class="home_link ui-btn ui-icon-home ui-btn-icon-left" data-icon="home">Home</a>
</header>
<div class="nav_container"></div>
<article class="gadget_container"></article>
<aside>
......
......@@ -11,8 +11,149 @@
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
var navigation_template,
/////////////////////////////////////////////////////////////////
// Minimalistic ERP5's like portal type configuration
/////////////////////////////////////////////////////////////////
var portal_types = {
"Input Module": {
"view": {
"gadget": "InputModule_viewInputList",
"type": "object_list",
"title": "Document List"
},
"view_fast_input": {
"gadget": "InputModule_viewAddDocumentDialog",
"type": "object_fast_input",
"title": "Create Document"
}
},
"Input": {
"view": {
"gadget": "Input_viewProductionLine",
"type": "object_view",
"title": "Production Line"
},
"view_table": {
"gadget": "Input_viewTable",
"type": "object_view",
"title": "Edit table"
},
"view_simu": {
"gadget": "Input_viewSimulation",
"type": "object_view",
"title": "Run simulation"
},
"view_management": {
"gadget": "Input_viewDocumentManagement",
"type": "object_view",
"title": "Manage document"
},
"view_result": {
"gadget": "Input_viewResultList",
"type": "object_view",
"title": "Results"
}
},
"Output": {
"view": {
"gadget": "Output_viewStationUtilisationGraph",
"type": "object_view",
"title": "Stations Utilization"
},
"view_queue_stat": {
"gadget": "Output_viewQueueStatGraph",
"type": "object_view",
"title": "Queues Statistics"
},
"view_exit_stat": {
"gadget": "Output_viewExitStatistics",
"type": "object_view",
"title": "Exit Statistics"
},
"view_gantt": {
"gadget": "Output_viewJobGantt",
"type": "object_view",
"title": "Job Gantt"
},
"view_schedule": {
"gadget": "Output_viewJobScheduleSpreadsheet",
"type": "object_view",
"title": "Job Schedule"
},
"view_debug": {
"gadget": "Output_viewDebugJson",
"type": "object_view",
"title": "Debug JSON"
}
}
},
panel_template,
navigation_template,
active_navigation_template,
gadget_klass = rJS(window);
function calculateTabHTML(gadget, options, key, title, active) {
return new RSVP.Queue()
.push(function () {
var kw = {
action: key,
id: options.id
};
if (options.result !== undefined) {
kw.result = options.result;
}
return gadget.aq_pleasePublishMyState(kw);
})
.push(function (url) {
var kw = {
title: title,
link: url
};
if (active === true) {
return active_navigation_template(kw);
}
return navigation_template(kw);
});
}
function calculateNavigationHTML(gadget, portal_type, options) {
var nav_html,
action;
if (portal_types[portal_type][options.action].type ===
"object_view") {
return new RSVP.Queue()
.push(function () {
var url_list = [],
key2;
for (key2 in portal_types[portal_type]) {
if (portal_types[portal_type].hasOwnProperty(key2)) {
action = portal_types[portal_type][key2];
if (action.type === "object_view") {
url_list.push(
calculateTabHTML(gadget, options, key2, action.title,
(key2 === options.action))
);
}
}
}
return RSVP.all(url_list);
})
.push(function (entry_list) {
var i;
nav_html =
'<nav data-role="navbar" data-collapsible="true"><ul>';
for (i = 0; i < entry_list.length; i += 1) {
nav_html += entry_list[i];
}
nav_html += '</ul></nav>';
return nav_html;
});
}
}
initGadgetMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
......@@ -71,35 +212,68 @@
// Hey, I want to display some URL
return this.aq_pleasePublishMyState({});
})
.allowPublicAcquisition("whoWantToDisplayThisPage", function (param_list) {
// Hey, I want to display some URL
return this.aq_pleasePublishMyState({page: param_list[0]});
})
.allowPublicAcquisition("whoWantToDisplayThisDocument",
function (param_list) {
// Hey, I want to display some jIO document
return this.aq_pleasePublishMyState({
page: "Input_viewTable",
id: param_list[0]
});
var kw = {
action: param_list[1] || "view"
};
if (param_list[0] !== undefined) {
kw.id = param_list[0];
}
return this.aq_pleasePublishMyState(kw);
})
.allowPublicAcquisition("whoWantToDisplayThisDocumentPage",
.allowPublicAcquisition("whoWantToDisplayThisResult",
function (param_list) {
// Hey, I want to display some jIO document
return this.aq_pleasePublishMyState({
page: param_list[0],
id: param_list[1]
action: "view",
id: param_list[0],
result: param_list[1]
});
})
.allowPublicAcquisition("getConfigurationDict", function (param_list) {
return this.props.configuration_dict;
})
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
.ready(function (g) {
if (panel_template === undefined) {
// XXX Only works as root gadget
panel_template = Handlebars.compile(
document.getElementById("panel-template").innerHTML
);
navigation_template = Handlebars.compile(
document.getElementById("navigation-template").innerHTML
);
active_navigation_template = Handlebars.compile(
document.getElementById("active-navigation-template").innerHTML
);
}
})
// Create some link on the page
.ready(function (g) {
return g.aq_pleasePublishMyState({})
.push(function (link) {
g.props.element.getElementsByClassName("home_link")[0].href = link;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
g.aq_pleasePublishMyState({}),
g.aq_pleasePublishMyState({action: "view_fast_input"})
]);
})
.push(function (link_list) {
var panel = g.props.element.querySelector("#leftpanel");
panel.innerHTML =
panel_template({navigationlist: []});
panel.getElementsByClassName("home_link")[0].href = link_list[0];
panel.getElementsByClassName("fast_input_link")[0].href =
link_list[1];
// XXX JQuery mobile
$(panel).trigger("create");
});
})
......@@ -125,19 +299,6 @@
});
})
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
.ready(function (g) {
if (navigation_template === undefined) {
// XXX Only works as root gadget
var source = document.getElementById("navigation-template")
.innerHTML;
navigation_template = Handlebars.compile(source);
}
})
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -146,48 +307,59 @@
.declareMethod("render", function (options) {
var gadget = this,
page_gadget,
portal_type = "Input Module",
nav_element = gadget.props.element
.getElementsByClassName("nav_container")[0],
element = gadget.props.element
.getElementsByClassName("gadget_container")[0];
options.configuration_dict = gadget.props.configuration_dict;
if (options.page === undefined) {
// Redirect to the about page
return gadget.aq_pleasePublishMyState({
page: "InputModule_viewInputList"
})
if (options.action === undefined) {
// Redirect to the view action
options.action = "view";
return gadget.aq_pleasePublishMyState(options)
.push(gadget.pleaseRedirectMyHash.bind(gadget));
}
return gadget.declareGadget(options.page + ".html")
// Detect what is the kind of document displayed
if (options.id !== undefined) {
if (options.result === undefined) {
portal_type = "Input";
} else {
portal_type = "Output";
}
}
// Get the action informations
return gadget.declareGadget(
portal_types[portal_type][options.action].gadget + ".html"
)
.push(function (g) {
page_gadget = g;
if (page_gadget.render !== undefined) {
return page_gadget.render(options);
}
}).push(function () {
var navigation_list = [];
if (page_gadget.getNavigationList !== undefined) {
navigation_list = page_gadget.getNavigationList();
}
return RSVP.all([
page_gadget.getTitle(),
page_gadget.getElement(),
navigation_list
calculateNavigationHTML(gadget, portal_type, options)
]);
}).push(function (result_list) {
var title = result_list[0],
page_element = result_list[1],
navigation_list = result_list[2],
panel = gadget.props.element.querySelector("#leftpanel");
var nav_html = result_list[1],
page_element = result_list[0];
// Update title
gadget.props.element.querySelector("header h1").textContent =
title;
portal_type;
while (panel.firstChild) {
panel.removeChild(panel.firstChild);
// Update the navigation panel
// Clear the previous rendering
while (nav_element.firstChild) {
nav_element.removeChild(nav_element.firstChild);
}
if (nav_html !== undefined) {
nav_element.innerHTML = nav_html;
$(nav_element).trigger("create");
}
panel.innerHTML =
navigation_template({navigationlist: navigation_list});
// XXX JQuery mobile
$(panel).trigger("create");
// Append in the DOM at the end to reduce flickering and reduce DOM
// modifications
......
......@@ -35,7 +35,7 @@
display: none !important;
}
.gadget_container, header {
.gadget_container, header, nav {
margin-left: @margin;
}
......
/*global console, RSVP */
(function (window, RSVP) {
"use strict";
window.initDocumentPageMixin = function (gadget_klass) {
gadget_klass
.declareAcquiredMethod("whoWantToDisplayThisDocumentPage",
"whoWantToDisplayThisDocumentPage")
.declareMethod("getNavigationList", function () {
var key = this.props.jio_key,
gadget = this;
return new RSVP.Queue()
.push(function () {
// XXX Conditional simulation menu
return RSVP.all([
gadget.whoWantToDisplayThisDocumentPage(
"Input_viewProductionLine",
key
),
gadget.whoWantToDisplayThisDocumentPage("Input_viewTable", key),
gadget.whoWantToDisplayThisDocumentPage(
"Input_viewSimulation",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Input_viewDocumentManagement",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Output_viewStationUtilisationGraph",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Output_viewQueueStatGraph",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Output_viewExitStatistics",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Output_viewJobGantt",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Output_viewJobScheduleSpreadsheet",
key
),
gadget.whoWantToDisplayThisDocumentPage(
"Output_viewDebugJson",
key
)
]);
})
.push(function (result_list) {
return [
{link: result_list[0], title: "Production line"},
{link: result_list[1], title: "Edit table"},
{link: result_list[2], title: "Run simulation"},
{link: result_list[3], title: "Manage document"},
{link: result_list[4], title: "Stations Utilization"},
{link: result_list[5], title: "Queues Statistics"},
{link: result_list[6], title: "Exit Statistics"},
{link: result_list[7], title: "Job Gantt"},
{link: result_list[8], title: "Job Schedule"},
{link: result_list[9], title: "Debug JSON"}
];
});
});
};
}(window, RSVP));
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