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

publish static version

parent 33e9cd92
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
"Start", "End" ] ], "Start", "End" ] ],
capacity_by_project_spreadsheet: [ [ "Project Name", "Sequence", "Capacity Requirements" ] ], capacity_by_project_spreadsheet: [ [ "Project Name", "Sequence", "Capacity Requirements" ] ],
capacity_by_station_spreadsheet: [ [ "Day", "CS1" ] ] capacity_by_station_spreadsheet: [ [ "Day", "CS1" ] ]
}, name = "FromScratch"; }, name = "Untitled";
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false); return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false);
}).push(function(evt) { }).push(function(evt) {
...@@ -66,12 +66,12 @@ ...@@ -66,12 +66,12 @@
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); 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; var gadget = this;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return RSVP.any([ waitForImport(gadget), waitForNew(gadget) ]); return RSVP.any([ waitForImport(gadget), waitForNew(gadget) ]);
}).push(function(result) { }).push(function(result) {
return gadget.whoWantToDisplayThisDocument(result.id); return gadget.whoWantsToDisplayThisDocument(result.id);
}).push(function(url) { }).push(function(url) {
return gadget.pleaseRedirectMyHash(url); return gadget.pleaseRedirectMyHash(url);
}); });
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
// Precompile the templates while loading the first gadget instance // 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); var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("table-template").innerHTML, table_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass); 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; var gadget = this;
return gadget.aq_allDocs({ return gadget.aq_allDocs({
select_list: [ "title", "modified" ] select_list: [ "title", "modified" ]
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
var result_list = [], doc, i; var result_list = [], doc, i;
for (i = 0; i < document_list.data.total_rows; i += 1) { for (i = 0; i < document_list.data.total_rows; i += 1) {
doc = document_list.data.rows[i]; 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); return RSVP.all(result_list);
}).push(function(document_list) { }).push(function(document_list) {
// Create new doc if nothing exists // Create new doc if nothing exists
if (document_list.length === 0) { 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); return gadget.pleaseRedirectMyHash(url);
}); });
} }
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
_mimetype: "application/json" _mimetype: "application/json"
}); });
}).push(function() { }).push(function() {
return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key); return gadget.whoWantsToDisplayThisDocument(gadget.props.jio_key);
}).push(function(url) { }).push(function(url) {
return gadget.pleaseRedirectMyHash(url); return gadget.pleaseRedirectMyHash(url);
}); });
...@@ -68,14 +68,14 @@ ...@@ -68,14 +68,14 @@
_id: gadget.props.jio_key _id: gadget.props.jio_key
}); });
}).push(function() { }).push(function() {
return gadget.whoWantToDisplayHome(); return gadget.whoWantsToDisplayHome();
}).push(function(url) { }).push(function(url) {
return gadget.pleaseRedirectMyHash(url); return gadget.pleaseRedirectMyHash(url);
}); });
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); 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; this.props.jio_key = options.id;
var gadget = this; var gadget = this;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
// Precompile the templates while loading the first gadget instance // 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); var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("table-template").innerHTML, table_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass); 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; var gadget = this;
this.props.jio_key = options.id; this.props.jio_key = options.id;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
}).push(function(sim_json) { }).push(function(sim_json) {
var document_list = JSON.parse(sim_json), result_list = [], i; var document_list = JSON.parse(sim_json), result_list = [], i;
for (i = 0; i < document_list.length; i += 1) { 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); return RSVP.all(result_list);
}).push(function(document_list) { }).push(function(document_list) {
......
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
_attachment: "body.json" _attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]); }), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) { }).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() { }).declareMethod("startService", function() {
var gadget = this; var gadget = this;
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
_mimetype: "application/json" _mimetype: "application/json"
}); });
}).push(function() { }).push(function() {
return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key, "view_result"); return gadget.whoWantsToDisplayThisDocument(gadget.props.jio_key, "view_result");
}).push(function(url) { }).push(function(url) {
return gadget.pleaseRedirectMyHash(url); return gadget.pleaseRedirectMyHash(url);
}); });
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
// Precompile the templates while loading the first gadget instance // Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); 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; var gadget = this, property_list, data;
this.props.jio_key = options.id; this.props.jio_key = options.id;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
......
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
_attachment: "body.json" _attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]); }), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) { }).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() { }).declareMethod("startService", function() {
var gadget = this; var gadget = this;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
return obj.parent ? "sub_task" : ""; return obj.parent ? "sub_task" : "";
}; };
function job_gantt_widget(all_data) { 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 = { var now = new Date(), start_date, gantt_data = {
data: [ { data: [ {
id: "by_order", id: "by_order",
...@@ -38,13 +40,13 @@ ...@@ -38,13 +40,13 @@
function isVisibleStation(station) { function isVisibleStation(station) {
// we should be able to define in the backend which // we should be able to define in the backend which
// station is visible // 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) { $.each(output_data.elementList.sort(function(a, b) {
return a.id < b.id ? -1 : 1; return a.id < b.id ? -1 : 1;
}), function(idx, obj) { }), function(idx, obj) {
var input_job = null, input_order = null, i, j, node, node_key, order, component, duration, seen_parts = {}; 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 corresponding input
// find the input order and order component for this job // find the input order and order component for this job
for (node_key in input_data.nodes) { for (node_key in input_data.nodes) {
...@@ -56,7 +58,7 @@ ...@@ -56,7 +58,7 @@
if (order.id === obj.id) { if (order.id === obj.id) {
input_job = input_order = order; input_job = input_order = order;
} }
if (input_job === null) { if (input_job === null && order.componentsList) {
for (j = 0; j < order.componentsList.length; j += 1) { for (j = 0; j < order.componentsList.length; j += 1) {
component = order.componentsList[j]; component = order.componentsList[j];
if (component.id === obj.id) { if (component.id === obj.id) {
...@@ -82,15 +84,17 @@ ...@@ -82,15 +84,17 @@
} }
seen_parts = {}; seen_parts = {};
$.each(obj.results.schedule, function(i, schedule) { $.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 // Filter intermediate steps in part job shop
if (isVisibleStation(schedule.stationId)) { if (isVisibleStation(schedule.stationId)) {
entrance_date = new Date(start_date.getTime()); if (schedule.exitTime) {
entrance_date.setTime(entrance_date.getTime() + schedule.entranceTime * 1e3 * 3600); duration = 24 * (schedule.exitTime - schedule.entranceTime);
if (obj.results.schedule[i + 1]) {
duration = obj.results.schedule[i + 1].entranceTime - schedule.entranceTime;
} else { } else {
duration = obj.results.completionTime - schedule.entranceTime; 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) { if (duration > 0) {
task_start_date = new Date(start_date.getTime()); task_start_date = new Date(start_date.getTime());
...@@ -98,7 +102,7 @@ ...@@ -98,7 +102,7 @@
// task_start_date.setDate(task_start_date.getDate() + // task_start_date.setDate(task_start_date.getDate() +
// schedule['entranceTime']); // schedule['entranceTime']);
// for simulation time unit as days hours // 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; job_full_id = input_job.id + "." + input_order.id;
if (seen_parts[job_full_id] === undefined) { if (seen_parts[job_full_id] === undefined) {
gantt_data.data.push({ gantt_data.data.push({
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
(function(window, rJS, RSVP, 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) {
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 ? // XXX why ?
now.setHours(0); now.setHours(0);
now.setMinutes(0); now.setMinutes(0);
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
// versa. // versa.
for (i = 0; i < output_data.elementList.length; i += 1) { for (i = 0; i < output_data.elementList.length; i += 1) {
obj = output_data.elementList[i]; obj = output_data.elementList[i];
if (obj._class === "Dream.Job") { if (obj._class === "Dream.Job" || obj._class === "Dream.CapacityProject") {
input_job = null; input_job = null;
input_order = null; input_order = null;
// find the input order and order component for this job // 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) { for (node_id in input_data.nodes) {
if (input_data.nodes.hasOwnProperty(node_id)) { if (input_data.nodes.hasOwnProperty(node_id)) {
node = input_data.nodes[node_id]; node = input_data.nodes[node_id];
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
if (order.id === obj.id) { if (order.id === obj.id) {
input_job = input_order = order; input_job = input_order = order;
} }
if (input_job === null) { if (input_job === null && order.componentsList) {
for (k = 0; k < order.componentsList.length; k += 1) { for (k = 0; k < order.componentsList.length; k += 1) {
component = order.componentsList[k]; component = order.componentsList[k];
if (component.id === obj.id) { if (component.id === obj.id) {
...@@ -39,12 +40,31 @@ ...@@ -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); due_date = new Date(simulation_start_date.getTime() + input_order.dueDate * 1e3 * 3600);
for (j = 0; j < obj.results.schedule.length; j += 1) { for (j = 0; j < obj.results.schedule.length; j += 1) {
schedule = obj.results.schedule[j]; schedule = obj.results.schedule[j];
entrance_date = new Date(simulation_start_date.getTime() + // XXX: time unit entrance_date = new Date(simulation_start_date.getTime() + // XXX: time unit
schedule.entranceTime * 1e3 * 3600); schedule.entranceTime * 1e3 * 3600);
duration = 0; 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 // Duration is calculated by difference of entranceTime of this
// step and entranceTime of the next step, or completionTime when // step and entranceTime of the next step, or completionTime when
// this is the last step // this is the last step
...@@ -55,7 +75,7 @@ ...@@ -55,7 +75,7 @@
} }
spreadsheet_data.push([ // XXX this label is incorrect for design step, during design spreadsheet_data.push([ // XXX this label is incorrect for design step, during design
// phase we still have an order and not an order component. // 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} @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 \ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Minimalistic ERP5's like portal type configuration // Minimalistic ERP5's like portal type configuration
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// XXX we should use lists instead to keep ordering
var portal_types = { var portal_types = {
"Input Module": { "Input Module": {
view: { view: {
...@@ -244,7 +245,7 @@ ...@@ -244,7 +245,7 @@
} }
} }
initGadgetMixin(gadget_klass); 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 this.getDeclaredGadget("jio").push(function(jio_gadget) {
return jio_gadget.allDocs.apply(jio_gadget, param_list); return jio_gadget.allDocs.apply(jio_gadget, param_list);
}); });
...@@ -272,11 +273,12 @@ ...@@ -272,11 +273,12 @@
return this.getDeclaredGadget("jio").push(function(jio_gadget) { return this.getDeclaredGadget("jio").push(function(jio_gadget) {
return jio_gadget.getAttachment.apply(jio_gadget, param_list); return jio_gadget.getAttachment.apply(jio_gadget, param_list);
}); });
}).allowPublicAcquisition("whoWantToDisplayHome", function() { }).allowPublicAcquisition("whoWantsToDisplayHome", function() {
// Hey, I want to display some URL // Hey, I want to display some URL
return this.aq_pleasePublishMyState({}); return this.aq_pleasePublishMyState({});
}).allowPublicAcquisition("whoWantToDisplayThisDocument", function(param_list) { }).allowPublicAcquisition("whoWantsToDisplayThisDocument", function(param_list) {
// Hey, I want to display some jIO document // Hey, I want to display some jIO document
// XXX should be merged with whoWantsToDisplayThisResult
var kw = { var kw = {
action: param_list[1] || "view" action: param_list[1] || "view"
}; };
...@@ -284,10 +286,21 @@ ...@@ -284,10 +286,21 @@
kw.id = param_list[0]; kw.id = param_list[0];
} }
return this.aq_pleasePublishMyState(kw); return this.aq_pleasePublishMyState(kw);
}).allowPublicAcquisition("whoWantToDisplayThisResult", function(param_list) { }).allowPublicAcquisition("whoWantsToDisplayThisResult", function(param_list) {
// Hey, I want to display some jIO document // 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({ return this.aq_pleasePublishMyState({
action: "view", action: action,
id: param_list[0], id: param_list[0],
result: param_list[1] result: param_list[1]
}); });
...@@ -351,7 +364,7 @@ ...@@ -351,7 +364,7 @@
back_kw.id = options.id; 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) { return gadget.declareGadget(portal_types[portal_type][options.action].gadget + ".html").push(function(g) {
page_gadget = g; page_gadget = g;
if (page_gadget.render !== undefined) { if (page_gadget.render !== undefined) {
......
/*global jQuery, rJS, window, JSON, RSVP */ /*global jQuery, rJS, window, JSON, RSVP */
(function(window, $, rJS, JSON, RSVP) { (function(window, $, rJS, JSON, RSVP) {
"use strict"; "use strict";
rJS(window).declareMethod("render", function(content) { rJS(window).declareMethod("render", function(content, options) {
var data = JSON.parse(content); var data = JSON.parse(content);
return this.getElement().push(function(element) { return this.getElement().push(function(element) {
$(element).find(".table-container").handsontable({ $(element).find(".table-container").handsontable($.extend({
data: data, data: data,
minSpareRows: 1,
stretchH: "all" stretchH: "all"
}); }, options || {}));
}); });
}).declareMethod("getData", function() { }).declareMethod("getData", function() {
return this.getElement().push(function(element) { return this.getElement().push(function(element) {
......
...@@ -33,5 +33,25 @@ ...@@ -33,5 +33,25 @@
equal(rows[0].childNodes[2].innerHTML, "data12"); equal(rows[0].childNodes[2].innerHTML, "data12");
}).always(start); }).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); })(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