Commit cd928569 authored by Jérome Perrin's avatar Jérome Perrin

publish static version

parent 33e9cd92
......@@ -47,7 +47,7 @@
"Start", "End" ] ],
capacity_by_project_spreadsheet: [ [ "Project Name", "Sequence", "Capacity Requirements" ] ],
capacity_by_station_spreadsheet: [ [ "Day", "CS1" ] ]
}, name = "FromScratch";
}, name = "Untitled";
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false);
}).push(function(evt) {
......@@ -66,12 +66,12 @@
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("startService", function() {
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("startService", function() {
var gadget = this;
return new RSVP.Queue().push(function() {
return RSVP.any([ waitForImport(gadget), waitForNew(gadget) ]);
}).push(function(result) {
return gadget.whoWantToDisplayThisDocument(result.id);
return gadget.whoWantsToDisplayThisDocument(result.id);
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
......
......@@ -8,7 +8,7 @@
// 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.declareAcquiredMethod("aq_allDocs", "allDocs").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("render", function() {
gadget_klass.declareAcquiredMethod("aq_allDocs", "jio_allDocs").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("render", function() {
var gadget = this;
return gadget.aq_allDocs({
select_list: [ "title", "modified" ]
......@@ -16,13 +16,13 @@
var result_list = [], doc, i;
for (i = 0; i < document_list.data.total_rows; i += 1) {
doc = document_list.data.rows[i];
result_list.push(RSVP.all([ gadget.whoWantToDisplayThisDocument(doc.id), doc.value.title, doc.value.modified ]));
result_list.push(RSVP.all([ gadget.whoWantsToDisplayThisDocument(doc.id), doc.value.title, doc.value.modified ]));
}
return RSVP.all(result_list);
}).push(function(document_list) {
// Create new doc if nothing exists
if (document_list.length === 0) {
return gadget.whoWantToDisplayThisDocument(undefined, "view_fast_input").push(function(url) {
return gadget.whoWantsToDisplayThisDocument(undefined, "view_fast_input").push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
}
......
......@@ -53,7 +53,7 @@
_mimetype: "application/json"
});
}).push(function() {
return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key);
return gadget.whoWantsToDisplayThisDocument(gadget.props.jio_key);
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
......@@ -68,14 +68,14 @@
_id: gadget.props.jio_key
});
}).push(function() {
return gadget.whoWantToDisplayHome();
return gadget.whoWantsToDisplayHome();
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_remove", "jio_remove").declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_get", "jio_get").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareAcquiredMethod("whoWantToDisplayHome", "whoWantToDisplayHome").declareMethod("render", function(options) {
gadget_klass.declareAcquiredMethod("aq_remove", "jio_remove").declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_get", "jio_get").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareAcquiredMethod("whoWantsToDisplayHome", "whoWantsToDisplayHome").declareMethod("render", function(options) {
this.props.jio_key = options.id;
var gadget = this;
return new RSVP.Queue().push(function() {
......
......@@ -8,7 +8,7 @@
// 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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("whoWantToDisplayThisResult", "whoWantToDisplayThisResult").declareMethod("render", function(options) {
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("whoWantsToDisplayThisResult", "whoWantsToDisplayThisResult").declareMethod("render", function(options) {
var gadget = this;
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
......@@ -23,7 +23,7 @@
}).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 ]));
result_list.push(RSVP.all([ gadget.whoWantsToDisplayThisResult(gadget.props.jio_key, i), document_list[i].score, document_list[i].key ]));
}
return RSVP.all(result_list);
}).push(function(document_list) {
......
......@@ -44,7 +44,9 @@
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet));
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet), {
minSpareRows: 1
});
});
}).declareMethod("startService", function() {
var gadget = this;
......
......@@ -71,7 +71,7 @@
_mimetype: "application/json"
});
}).push(function() {
return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key, "view_result");
return gadget.whoWantsToDisplayThisDocument(gadget.props.jio_key, "view_result");
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
......@@ -103,7 +103,7 @@
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("aq_getConfigurationDict", "getConfigurationDict").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("render", function(options) {
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("aq_getConfigurationDict", "getConfigurationDict").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("render", function(options) {
var gadget = this, property_list, data;
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
......
......@@ -44,7 +44,9 @@
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet));
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet), {
minSpareRows: 1
});
});
}).declareMethod("startService", function() {
var gadget = this;
......
......@@ -7,6 +7,8 @@
return obj.parent ? "sub_task" : "";
};
function job_gantt_widget(all_data) {
// XXX: use dhx_gantt zoom level feature (
// http://dhtmlx.com/docs/products/dhtmlxGantt/02_features.html )
var now = new Date(), start_date, gantt_data = {
data: [ {
id: "by_order",
......@@ -38,13 +40,13 @@
function isVisibleStation(station) {
// we should be able to define in the backend which
// station is visible
return input_data.nodes[station]._class !== "Dream.QueueManagedJob" && input_data.nodes[station]._class !== "Dream.OperatorManagedJob" && input_data.nodes[station]._class !== "Dream.ExitJobShop";
return input_data.nodes[station]._class !== "Dream.QueueManagedJob" && input_data.nodes[station]._class !== "Dream.OperatorManagedJob" && input_data.nodes[station]._class !== "Dream.ExitJobShop" && input_data.nodes[station]._class !== "Dream.CapacityStationBuffer" && input_data.nodes[station]._class !== "Dream.CapacityStationExit" && input_data.nodes[station]._class !== "Dream.Queue";
}
$.each(output_data.elementList.sort(function(a, b) {
return a.id < b.id ? -1 : 1;
}), function(idx, obj) {
var input_job = null, input_order = null, i, j, node, node_key, order, component, duration, seen_parts = {};
if (obj._class === "Dream.Job") {
if (obj._class === "Dream.Job" || obj._class === "Dream.CapacityProject") {
// find the corresponding input
// find the input order and order component for this job
for (node_key in input_data.nodes) {
......@@ -56,7 +58,7 @@
if (order.id === obj.id) {
input_job = input_order = order;
}
if (input_job === null) {
if (input_job === null && order.componentsList) {
for (j = 0; j < order.componentsList.length; j += 1) {
component = order.componentsList[j];
if (component.id === obj.id) {
......@@ -82,23 +84,25 @@
}
seen_parts = {};
$.each(obj.results.schedule, function(i, schedule) {
var entrance_date, task_start_date, job_full_id;
var task_start_date, job_full_id;
// Filter intermediate steps in part job shop
if (isVisibleStation(schedule.stationId)) {
entrance_date = new Date(start_date.getTime());
entrance_date.setTime(entrance_date.getTime() + schedule.entranceTime * 1e3 * 3600);
if (schedule.exitTime) {
duration = 24 * (schedule.exitTime - schedule.entranceTime);
} else {
if (obj.results.schedule[i + 1]) {
duration = obj.results.schedule[i + 1].entranceTime - schedule.entranceTime;
} else {
duration = obj.results.completionTime - schedule.entranceTime;
}
}
if (duration > 0) {
task_start_date = new Date(start_date.getTime());
// for simulation time unit as days
// task_start_date.setDate(task_start_date.getDate() +
// schedule['entranceTime']);
// for simulation time unit as days hours
task_start_date.setTime(task_start_date.getTime() + schedule.entranceTime * 1e3 * 3600);
task_start_date.setTime(task_start_date.getTime() + schedule.entranceTime * 1e3 * 3600 * 24);
job_full_id = input_job.id + "." + input_order.id;
if (seen_parts[job_full_id] === undefined) {
gantt_data.data.push({
......
......@@ -3,7 +3,7 @@
(function(window, rJS, RSVP, moment, initGadgetMixin) {
"use strict";
function job_schedule_spreadsheet_widget(all_data) {
var now = new Date(), input_data = all_data.input, output_data = all_data.result, spreadsheet_data = [], spreadsheet_header = [ [ "Jobs", "ID", "Project Manager", "Due Date", "Priority", "Entrance Time", "Processing Time", "Station ID", "Step No." ] ], simulation_start_date = new Date(input_data.general.currentDate || now.getTime()), i, j, k, obj, node, component, order, node_id, due_date, entrance_date, duration, schedule, input_job = null, input_order = null;
var now = new Date(), name, input_data = all_data.input, output_data = all_data.result, spreadsheet_data = [], spreadsheet_header = [ [ "Jobs", "ID", "Project Manager", "Due Date", "Priority", "Entrance Time", "Processing Time", "Station ID", "Step No." ] ], simulation_start_date = new Date(input_data.general.currentDate || now.getTime()), i, j, k, obj, node, component, order, node_id, due_date, entrance_date, duration, schedule, input_job = null, input_order = null;
// XXX why ?
now.setHours(0);
now.setMinutes(0);
......@@ -13,10 +13,11 @@
// versa.
for (i = 0; i < output_data.elementList.length; i += 1) {
obj = output_data.elementList[i];
if (obj._class === "Dream.Job") {
if (obj._class === "Dream.Job" || obj._class === "Dream.CapacityProject") {
input_job = null;
input_order = null;
// find the input order and order component for this job
// XXX this has no real meaning with capacity project
for (node_id in input_data.nodes) {
if (input_data.nodes.hasOwnProperty(node_id)) {
node = input_data.nodes[node_id];
......@@ -26,7 +27,7 @@
if (order.id === obj.id) {
input_job = input_order = order;
}
if (input_job === null) {
if (input_job === null && order.componentsList) {
for (k = 0; k < order.componentsList.length; k += 1) {
component = order.componentsList[k];
if (component.id === obj.id) {
......@@ -39,12 +40,31 @@
}
}
}
// XXX does not make sense in the case of capacity project
due_date = new Date(simulation_start_date.getTime() + input_order.dueDate * 1e3 * 3600);
for (j = 0; j < obj.results.schedule.length; j += 1) {
schedule = obj.results.schedule[j];
entrance_date = new Date(simulation_start_date.getTime() + // XXX: time unit
schedule.entranceTime * 1e3 * 3600);
duration = 0;
if (schedule.exitTime) {
duration = schedule.exitTime - schedule.entranceTime * 24;
} else {
// When duration is not returned by ManPy, it is calculated by
// difference of entranceTime of this step and entranceTime of the
// next step, or completionTime when this is the last step
if (i + 1 === obj.results.schedule.length) {
duration = obj.results.completionTime - schedule.entranceTime;
} else {
duration = obj.results.schedule[i + 1].entranceTime - schedule.entranceTime;
}
}
name = "";
if (obj._class === "Dream.CapacityProject") {
name = input_order.name + "-" + schedule.stationId;
} else {
name = input_order.name + "-" + input_job.name;
}
// Duration is calculated by difference of entranceTime of this
// step and entranceTime of the next step, or completionTime when
// this is the last step
......@@ -55,7 +75,7 @@
}
spreadsheet_data.push([ // XXX this label is incorrect for design step, during design
// phase we still have an order and not an order component.
input_order.name + "-" + input_job.name, obj.id, input_order.manager, moment(due_date).format("YYYY/MM/DD"), input_order.priority, moment(entrance_date).format("MMM/DD HH:mm"), duration, schedule.stationId, j ]);
name, obj.id, input_order.manager, moment(due_date).format("YYYY/MM/DD"), input_order.priority, moment(entrance_date).format("MMM/DD HH:mm"), duration, schedule.stationId, j ]);
}
}
}
......
@media (min-width:35em){.jqm-navmenu-panel.ui-panel-closed{visibility:visible!important;width:17em;-webkit-transition:none!important;-moz-transition:none!important;transition:none!important;-webkit-transform:none!important;-moz-transform:none!important;transform:none!important;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;height:100%;position:absolute;display:block}.ui-panel-page-content-open{width:auto}.ui-panel-page-content-open.ui-panel-page-content-position-left{margin-right:17em}.ui-panel-dismiss,.menu_link{display:none!important}.gadget_container,header,nav{margin-left:17em}.close-entry{display:none!important}.gadget_container{padding:1em}}[data-gadget-scope=productionline_toolbox]{position:relative;width:19.5%;float:left}[data-gadget-scope=productionline_graph]{position:relative;width:79.5%;float:right}
\ No newline at end of file
@media (min-width:110em){.jqm-navmenu-panel.ui-panel-closed{visibility:visible!important;width:17em;-webkit-transition:none!important;-moz-transition:none!important;transition:none!important;-webkit-transform:none!important;-moz-transform:none!important;transform:none!important;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;height:100%;position:absolute;display:block}.ui-panel-page-content-open{width:auto}.ui-panel-page-content-open.ui-panel-page-content-position-left{margin-right:17em}.ui-panel-dismiss,.menu_link{display:none!important}.gadget_container,header,nav{margin-left:17em}.close-entry{display:none!important}.gadget_container{padding:1em}}[data-gadget-scope=productionline_toolbox]{position:relative;width:19.5%;float:left}[data-gadget-scope=productionline_graph]{position:relative;width:79.5%;float:right}
\ No newline at end of file
......@@ -12,6 +12,7 @@
/////////////////////////////////////////////////////////////////
// Minimalistic ERP5's like portal type configuration
/////////////////////////////////////////////////////////////////
// XXX we should use lists instead to keep ordering
var portal_types = {
"Input Module": {
view: {
......@@ -244,7 +245,7 @@
}
}
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("allDocs", function(param_list) {
gadget_klass.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("jio_allDocs", function(param_list) {
return this.getDeclaredGadget("jio").push(function(jio_gadget) {
return jio_gadget.allDocs.apply(jio_gadget, param_list);
});
......@@ -272,11 +273,12 @@
return this.getDeclaredGadget("jio").push(function(jio_gadget) {
return jio_gadget.getAttachment.apply(jio_gadget, param_list);
});
}).allowPublicAcquisition("whoWantToDisplayHome", function() {
}).allowPublicAcquisition("whoWantsToDisplayHome", function() {
// Hey, I want to display some URL
return this.aq_pleasePublishMyState({});
}).allowPublicAcquisition("whoWantToDisplayThisDocument", function(param_list) {
}).allowPublicAcquisition("whoWantsToDisplayThisDocument", function(param_list) {
// Hey, I want to display some jIO document
// XXX should be merged with whoWantsToDisplayThisResult
var kw = {
action: param_list[1] || "view"
};
......@@ -284,10 +286,21 @@
kw.id = param_list[0];
}
return this.aq_pleasePublishMyState(kw);
}).allowPublicAcquisition("whoWantToDisplayThisResult", function(param_list) {
}).allowPublicAcquisition("whoWantsToDisplayThisResult", function(param_list) {
// Hey, I want to display some jIO document
// We'll display the result using the first enabled action
var action = "view", action_info, action_id;
for (action_id in portal_types.Output) {
if (portal_types.Output.hasOwnProperty(action_id)) {
action_info = portal_types.Output[action_id];
if (action_info.condition === undefined || action_info.condition(this)) {
action = action_id;
break;
}
}
}
return this.aq_pleasePublishMyState({
action: "view",
action: action,
id: param_list[0],
result: param_list[1]
});
......@@ -351,7 +364,7 @@
back_kw.id = options.id;
}
}
// Get the action informations
// Get the action information
return gadget.declareGadget(portal_types[portal_type][options.action].gadget + ".html").push(function(g) {
page_gadget = g;
if (page_gadget.render !== undefined) {
......
/*global jQuery, rJS, window, JSON, RSVP */
(function(window, $, rJS, JSON, RSVP) {
"use strict";
rJS(window).declareMethod("render", function(content) {
rJS(window).declareMethod("render", function(content, options) {
var data = JSON.parse(content);
return this.getElement().push(function(element) {
$(element).find(".table-container").handsontable({
$(element).find(".table-container").handsontable($.extend({
data: data,
minSpareRows: 1,
stretchH: "all"
});
}, options || {}));
});
}).declareMethod("getData", function() {
return this.getElement().push(function(element) {
......
......@@ -33,5 +33,25 @@
equal(rows[0].childNodes[2].innerHTML, "data12");
}).always(start);
});
test("the gadget can be configured", function() {
var hstable_gadget;
stop();
g.declareGadget("./index.html", {
element: document.querySelector("#qunit-fixture")
}).then(function(new_gadget) {
hstable_gadget = new_gadget;
return hstable_gadget.render(sample, {
minSpareRows: 1
});
}).then(function() {
var rows = $("table tbody tr");
// There is one spare row
equal(rows.length, 4);
}).then(function() {
return hstable_gadget.getData();
}).then(function(data) {
equal(data, JSON.stringify([ [ "row1", "data11", "data12", "data13" ], [ "row2", "data21", "data22", "data23" ], [ "row3", "data31", "data32", "data33" ], [ null, null, null, null ] ]));
}).always(start);
});
});
})(rJS, JSON, QUnit, jQuery);
\ No newline at end of file
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