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 @@ ...@@ -21,8 +21,6 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("aq_allDocs", "allDocs") .declareAcquiredMethod("aq_allDocs", "allDocs")
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash") .declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
.declareAcquiredMethod("whoWantToDisplayThisPage",
"whoWantToDisplayThisPage")
.declareAcquiredMethod("whoWantToDisplayThisDocument", .declareAcquiredMethod("whoWantToDisplayThisDocument",
"whoWantToDisplayThisDocument") "whoWantToDisplayThisDocument")
...@@ -33,9 +31,7 @@ ...@@ -33,9 +31,7 @@
var gadget = this; var gadget = this;
return gadget.aq_allDocs({"select_list": ["title", "modified"]}) return gadget.aq_allDocs({"select_list": ["title", "modified"]})
.push(function (document_list) { .push(function (document_list) {
var result_list = [gadget.whoWantToDisplayThisPage( var result_list = [],
"InputModule_viewAddDocumentDialog"
)],
doc, doc,
i; i;
for (i = 0; i < document_list.data.total_rows; i += 1) { for (i = 0; i < document_list.data.total_rows; i += 1) {
...@@ -50,16 +46,23 @@ ...@@ -50,16 +46,23 @@
}) })
.push(function (document_list) { .push(function (document_list) {
// Create new doc if nothing exists // Create new doc if nothing exists
if (document_list.length === 1) { if (document_list.length === 0) {
return gadget.pleaseRedirectMyHash(document_list[0]); return gadget
.whoWantToDisplayThisDocument(
undefined,
"view_fast_input"
)
.push(function (url) {
return gadget.pleaseRedirectMyHash(url);
});
} }
var i, var i,
parameter_list = [], parameter_list = [],
doc; doc;
for (i = 1; i < document_list.length; i += 1) { for (i = 0; i < document_list.length; i += 1) {
doc = document_list[i]; doc = document_list[i];
parameter_list[i - 1] = { parameter_list[i] = {
link: doc[0], link: doc[0],
title: doc[1] + " (" + doc[2] + ")" title: doc[1] + " (" + doc[2] + ")"
}; };
...@@ -72,12 +75,5 @@ ...@@ -72,12 +75,5 @@
documentlist: parameter_list 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)); }(window, rJS, RSVP, Handlebars, initGadgetMixin));
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.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> <script src="Input_viewDocumentManagement.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, /*global console, rJS, RSVP, jQuery,
promiseEventListener, initGadgetMixin */ promiseEventListener, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, $, promiseEventListener, (function (window, rJS, RSVP, $, promiseEventListener,
initGadgetMixin) { initGadgetMixin) {
"use strict"; "use strict";
...@@ -104,7 +104,6 @@ ...@@ -104,7 +104,6 @@
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -153,5 +152,5 @@ ...@@ -153,5 +152,5 @@
waitForKnowledgeExtraction(this) waitForKnowledgeExtraction(this)
]); ]);
}); });
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, promiseEventListener, }(window, rJS, RSVP, jQuery, promiseEventListener,
initGadgetMixin)); initGadgetMixin));
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script> <script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.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> <script src="Input_viewProductionLine.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global window, rJS, RSVP, initDocumentPageMixin */ /*global window, rJS, RSVP */
(function (window, rJS, RSVP, initDocumentPageMixin) { (function (window, rJS, RSVP) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
.ready(function (g) { .ready(function (g) {
...@@ -41,4 +40,4 @@ ...@@ -41,4 +40,4 @@
return productionline.startService(); 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 @@ ...@@ -16,7 +16,6 @@
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.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> <script src="Input_viewSimulation.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars, /*global rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin */ promiseEventListener, initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, $, Handlebars, (function (window, rJS, RSVP, $, Handlebars,
promiseEventListener, initGadgetMixin) { promiseEventListener, initGadgetMixin) {
"use strict"; "use strict";
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
label_template = Handlebars.compile(source); label_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -24,9 +23,10 @@ ...@@ -24,9 +23,10 @@
.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment") .declareAcquiredMethod("aq_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("aq_putAttachment", "jio_putAttachment") .declareAcquiredMethod("aq_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("aq_ajax", "jio_ajax") .declareAcquiredMethod("aq_ajax", "jio_ajax")
.declareAcquiredMethod("aq_getConfigurationDict", "getConfigurationDict")
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash") .declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
.declareAcquiredMethod("whoWantToDisplayThisDocumentPage", .declareAcquiredMethod("whoWantToDisplayThisDocument",
"whoWantToDisplayThisDocumentPage") "whoWantToDisplayThisDocument")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -39,20 +39,10 @@ ...@@ -39,20 +39,10 @@
.querySelector(".simulation_parameters"), .querySelector(".simulation_parameters"),
value, value,
queue, queue,
data, data;
property_list =
options.configuration_dict['Dream-Configuration'].property_list;
this.props.jio_key = options.id; 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) { function addField(property, value) {
var sub_gadget; var sub_gadget;
queue queue
...@@ -80,6 +70,17 @@ ...@@ -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) { for (i = 0; i < property_list.length; i += 1) {
property = property_list[i]; property = property_list[i];
if (property._class === "Dream.Property") { if (property._class === "Dream.Property") {
...@@ -87,6 +88,7 @@ ...@@ -87,6 +88,7 @@
addField(property, value); addField(property, value);
} }
} }
});
return queue; return queue;
}) })
...@@ -142,14 +144,14 @@ ...@@ -142,14 +144,14 @@
}); });
}) })
.push(function (result) { .push(function (result) {
return gadget.whoWantToDisplayThisDocumentPage( return gadget.whoWantToDisplayThisDocument(
"Output_viewDebugJson", gadget.props.jio_key,
gadget.props.jio_key "view_result"
); );
}) })
.push(function (url) { .push(function (url) {
return gadget.pleaseRedirectMyHash(url); return gadget.pleaseRedirectMyHash(url);
}); });
}); });
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars, }(window, rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin)); promiseEventListener, initGadgetMixin));
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<script src="../<%= copy.renderjs.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_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> <script src="Input_viewTable.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, initGadgetMixin */ /*global console, rJS, RSVP, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin) { (function (window, rJS, RSVP, initGadgetMixin) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -42,4 +41,4 @@ ...@@ -42,4 +41,4 @@
return tableeditor.startService(); return tableeditor.startService();
}); });
}); });
}(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin)); }(window, rJS, RSVP, initGadgetMixin));
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script> <script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.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_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> <script src="Output_viewDebugJson.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, initGadgetMixin */ /*global console, rJS, RSVP, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin) { (function (window, rJS, RSVP, initGadgetMixin) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -17,28 +16,20 @@ ...@@ -17,28 +16,20 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this; var gadget = this;
this.props.jio_key = options.id; this.props.jio_key = options.id;
this.props.result = options.result;
return new RSVP.Queue() return gadget.aq_getAttachment({
.push(function () {
return RSVP.all([
gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
}),
gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "simulation.json"
}) })
]); .push(function (result_json) {
}) var result = JSON.parse(result_json);
.push(function (result_list) {
gadget.props.element.querySelector(".json_input").textContent = gadget.props.element.querySelector(".json_input").textContent =
result_list[0]; JSON.stringify(result[gadget.props.result].input);
// XXX Hardcoded result
gadget.props.element.querySelector(".json_output").textContent = 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 @@ ...@@ -8,7 +8,6 @@
<script src="../<%= copy.renderjs.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 src="../<%= copy.handlebars.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" 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 src="Output_viewExitStatistics.js" type="text/javascript"></script>
<script id="interval-through-metric-template" type="text/x-handlebars-template"> <script id="interval-through-metric-template" type="text/x-handlebars-template">
......
/*global console, rJS, RSVP, initDocumentPageMixin, Handlebars, /*global console, rJS, RSVP, Handlebars,
initGadgetMixin */ initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, Handlebars, (function (window, rJS, RSVP, Handlebars,
initGadgetMixin) { initGadgetMixin) {
"use strict"; "use strict";
...@@ -125,7 +125,6 @@ ...@@ -125,7 +125,6 @@
} }
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -139,6 +138,7 @@ ...@@ -139,6 +138,7 @@
var jio_key = options.id, var jio_key = options.id,
gadget = this; gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
...@@ -146,10 +146,9 @@ ...@@ -146,10 +146,9 @@
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
var result = calculate_exit_stat( var result = calculate_exit_stat(
// XXX Hardcoded result JSON.parse(simulation_json)[gadget.props.result].result
JSON.parse(simulation_json)[0].result
); );
gadget.props.element.innerHTML = result; gadget.props.element.innerHTML = result;
}); });
}); });
}(window, rJS, RSVP, initDocumentPageMixin, Handlebars, initGadgetMixin)); }(window, rJS, RSVP, Handlebars, initGadgetMixin));
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script> <script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.dhtmlxganttjs.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_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> <script src="Output_viewJobGantt.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, gantt, /*global console, rJS, RSVP, jQuery, gantt,
initGadgetMixin */ initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, $, gantt, (function (window, rJS, RSVP, $, gantt,
initGadgetMixin) { initGadgetMixin) {
"use strict"; "use strict";
...@@ -203,7 +203,6 @@ ...@@ -203,7 +203,6 @@
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -217,6 +216,7 @@ ...@@ -217,6 +216,7 @@
var jio_key = options.id, var jio_key = options.id,
gadget = this; gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
...@@ -224,8 +224,7 @@ ...@@ -224,8 +224,7 @@
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.result = job_gantt_widget( gadget.props.result = job_gantt_widget(
// XXX Hardcoded result JSON.parse(simulation_json)[gadget.props.result]
JSON.parse(simulation_json)[0]
); );
}); });
}) })
...@@ -258,4 +257,4 @@ ...@@ -258,4 +257,4 @@
throw error; throw error;
}); });
}); });
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, gantt, initGadgetMixin)); }(window, rJS, RSVP, jQuery, gantt, initGadgetMixin));
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<script src="../<%= curl.momentjs.relative_dest %>" type="text/javascript"></script> <script src="../<%= curl.momentjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" 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> <script src="Output_viewJobScheduleSpreadsheet.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin */ /*global console, rJS, RSVP, moment, initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin) { (function (window, rJS, RSVP, moment, initGadgetMixin) {
"use strict"; "use strict";
function job_schedule_spreadsheet_widget(all_data) { function job_schedule_spreadsheet_widget(all_data) {
...@@ -150,7 +150,6 @@ ...@@ -150,7 +150,6 @@
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -165,6 +164,7 @@ ...@@ -165,6 +164,7 @@
var jio_key = options.id, var jio_key = options.id,
gadget = this; gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -180,8 +180,7 @@ ...@@ -180,8 +180,7 @@
return result_list[1].render( return result_list[1].render(
JSON.stringify( JSON.stringify(
job_schedule_spreadsheet_widget( job_schedule_spreadsheet_widget(
// XXX Hardcoded result JSON.parse(result_list[0])[gadget.props.result]
JSON.parse(result_list[0])[0]
) )
) )
); );
...@@ -206,4 +205,4 @@ ...@@ -206,4 +205,4 @@
return tableeditor.startService(); return tableeditor.startService();
}); });
}); });
}(window, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin)); }(window, rJS, RSVP, moment, initGadgetMixin));
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<script src="../<%= curl.jqueryflot.relative_dest %>"></script> <script src="../<%= curl.jqueryflot.relative_dest %>"></script>
<script src="../<%= curl.jqueryflotstack.relative_dest %>"></script> <script src="../<%= curl.jqueryflotstack.relative_dest %>"></script>
<script src="mixin_gadget.js" 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_viewQueueStatGraph.js" type="text/javascript"></script> <script src="Output_viewQueueStatGraph.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin */ /*global console, rJS, RSVP, jQuery, initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function (window, rJS, RSVP, initDocumentPageMixin, $, initGadgetMixin) { (function (window, rJS, RSVP, $, initGadgetMixin) {
"use strict"; "use strict";
function queue_stat_widget(output_data) { function queue_stat_widget(output_data) {
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -33,6 +32,7 @@ ...@@ -33,6 +32,7 @@
var jio_key = options.id, var jio_key = options.id,
gadget = this; gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.series = queue_stat_widget( gadget.props.series = queue_stat_widget(
// XXX Hardcoded result JSON.parse(simulation_json)[gadget.props.result].result
JSON.parse(simulation_json)[0].result
); );
}); });
}) })
...@@ -53,4 +52,4 @@ ...@@ -53,4 +52,4 @@
this.props.series this.props.series
); );
}); });
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin)); }(window, rJS, RSVP, jQuery, initGadgetMixin));
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<script src="../<%= curl.jqueryflot.relative_dest %>"></script> <script src="../<%= curl.jqueryflot.relative_dest %>"></script>
<script src="../<%= curl.jqueryflotstack.relative_dest %>"></script> <script src="../<%= curl.jqueryflotstack.relative_dest %>"></script>
<script src="mixin_gadget.js" 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_viewStationUtilisationGraph.js" type="text/javascript"></script> <script src="Output_viewStationUtilisationGraph.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin */ /*global console, rJS, RSVP, jQuery, initGadgetMixin */
(function (window, rJS, RSVP, initDocumentPageMixin, $, initGadgetMixin) { (function (window, rJS, RSVP, $, initGadgetMixin) {
"use strict"; "use strict";
function station_utilisation_graph_widget(output_data) { function station_utilisation_graph_widget(output_data) {
...@@ -124,7 +124,6 @@ ...@@ -124,7 +124,6 @@
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -138,6 +137,7 @@ ...@@ -138,6 +137,7 @@
var jio_key = options.id, var jio_key = options.id,
gadget = this; gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
...@@ -145,8 +145,7 @@ ...@@ -145,8 +145,7 @@
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.result_list = station_utilisation_graph_widget( gadget.props.result_list = station_utilisation_graph_widget(
// XXX Hardcoded result JSON.parse(simulation_json)[gadget.props.result].result
JSON.parse(simulation_json)[0].result
); );
}); });
}) })
...@@ -159,4 +158,4 @@ ...@@ -159,4 +158,4 @@
this.props.result_list[1] this.props.result_list[1]
); );
}); });
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin)); }(window, rJS, RSVP, jQuery, initGadgetMixin));
...@@ -16,13 +16,24 @@ ...@@ -16,13 +16,24 @@
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="index.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"> <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}} {{#navigationlist}}
<li><a href="{{link}}">{{title}}</a></li> <li><a href="{{link}}">{{title}}</a></li>
{{/navigationlist}} {{/navigationlist}}
</ul> </ul>
</script> </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> </head>
<body> <body>
...@@ -36,11 +47,14 @@ ...@@ -36,11 +47,14 @@
</div> </div>
<header data-role="header"> <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> <h1>Dream Simulation</h1>
<a class="home_link ui-btn ui-icon-home ui-btn-icon-left" data-icon="home">Home</a>
</header> </header>
<div class="nav_container"></div>
<article class="gadget_container"></article> <article class="gadget_container"></article>
<aside> <aside>
......
...@@ -11,8 +11,149 @@ ...@@ -11,8 +11,149 @@
$.mobile.hashListeningEnabled = false; $.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = 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); 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); initGadgetMixin(gadget_klass);
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -71,35 +212,68 @@ ...@@ -71,35 +212,68 @@
// Hey, I want to display some URL // Hey, I want to display some URL
return this.aq_pleasePublishMyState({}); 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", .allowPublicAcquisition("whoWantToDisplayThisDocument",
function (param_list) { function (param_list) {
// Hey, I want to display some jIO document // Hey, I want to display some jIO document
return this.aq_pleasePublishMyState({ var kw = {
page: "Input_viewTable", action: param_list[1] || "view"
id: param_list[0] };
}); if (param_list[0] !== undefined) {
kw.id = param_list[0];
}
return this.aq_pleasePublishMyState(kw);
}) })
.allowPublicAcquisition("whoWantToDisplayThisDocumentPage", .allowPublicAcquisition("whoWantToDisplayThisResult",
function (param_list) { function (param_list) {
// Hey, I want to display some jIO document // Hey, I want to display some jIO document
return this.aq_pleasePublishMyState({ return this.aq_pleasePublishMyState({
page: param_list[0], action: "view",
id: param_list[1] id: param_list[0],
result: param_list[1]
}); });
}) })
.allowPublicAcquisition("getConfigurationDict", function (param_list) {
return this.props.configuration_dict;
})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// ready // 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 // Create some link on the page
.ready(function (g) { .ready(function (g) {
return g.aq_pleasePublishMyState({}) return new RSVP.Queue()
.push(function (link) { .push(function () {
g.props.element.getElementsByClassName("home_link")[0].href = link; 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 @@ ...@@ -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 // declared methods
...@@ -146,48 +307,59 @@ ...@@ -146,48 +307,59 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
page_gadget, page_gadget,
portal_type = "Input Module",
nav_element = gadget.props.element
.getElementsByClassName("nav_container")[0],
element = gadget.props.element element = gadget.props.element
.getElementsByClassName("gadget_container")[0]; .getElementsByClassName("gadget_container")[0];
options.configuration_dict = gadget.props.configuration_dict;
if (options.page === undefined) { if (options.action === undefined) {
// Redirect to the about page // Redirect to the view action
return gadget.aq_pleasePublishMyState({ options.action = "view";
page: "InputModule_viewInputList" return gadget.aq_pleasePublishMyState(options)
})
.push(gadget.pleaseRedirectMyHash.bind(gadget)); .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) { .push(function (g) {
page_gadget = g; page_gadget = g;
if (page_gadget.render !== undefined) { if (page_gadget.render !== undefined) {
return page_gadget.render(options); return page_gadget.render(options);
} }
}).push(function () { }).push(function () {
var navigation_list = [];
if (page_gadget.getNavigationList !== undefined) {
navigation_list = page_gadget.getNavigationList();
}
return RSVP.all([ return RSVP.all([
page_gadget.getTitle(),
page_gadget.getElement(), page_gadget.getElement(),
navigation_list calculateNavigationHTML(gadget, portal_type, options)
]); ]);
}).push(function (result_list) { }).push(function (result_list) {
var title = result_list[0], var nav_html = result_list[1],
page_element = result_list[1], page_element = result_list[0];
navigation_list = result_list[2],
panel = gadget.props.element.querySelector("#leftpanel");
// Update title
gadget.props.element.querySelector("header h1").textContent = gadget.props.element.querySelector("header h1").textContent =
title; portal_type;
while (panel.firstChild) { // Update the navigation panel
panel.removeChild(panel.firstChild); // 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 // Append in the DOM at the end to reduce flickering and reduce DOM
// modifications // modifications
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
display: none !important; display: none !important;
} }
.gadget_container, header { .gadget_container, header, nav {
margin-left: @margin; 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