Commit 6e237982 authored by Jérome Perrin's avatar Jérome Perrin

update static version

parent a362559b
......@@ -56,7 +56,7 @@
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
var content, result = JSON.parse(result_list[0]), handsontable_options = {
var content, i, ctrlflag = true, def = [], result = JSON.parse(result_list[0]), handsontable_options = {
minSpareRows: 1,
onChange: function() {
if (gadget.timeout) {
......@@ -70,6 +70,23 @@
content = result.input[gadget.props.name];
} else {
content = options.action_definition.configuration.columns;
// XXX this is for the case of the initial setup
// if the content is not an array of arrays then create one
// from the content
for (i = 0; i <= content.length - 1; i += 1) {
if (!(content[i].constructor === Array)) {
def.push(content[i].name);
} else {
// otherwise do not modify anything
def = content;
ctrlflag = false;
break;
}
}
if (ctrlflag) {
def = [ def ];
}
content = def;
}
$.extend(handsontable_options, options.action_definition.configuration.handsontable_options || {});
return result_list[1].render(JSON.stringify(content), handsontable_options);
......
......@@ -2,25 +2,10 @@
(function(window, $, rJS, JSON, RSVP) {
"use strict";
rJS(window).declareMethod("render", function(content, options) {
var data = JSON.parse(content), i, ctrlflag = true, def = [];
// if the content is not an array of arrays then create one
// from the content
for (i = 0; i <= data.length - 1; i += 1) {
if (!(data[i].constructor === Array)) {
def.push(data[i].name);
} else {
// otherwise do not modify anything
def = data;
ctrlflag = false;
break;
}
}
if (ctrlflag) {
def = [ def ];
}
var data = JSON.parse(content);
return this.getElement().push(function(element) {
$(element).find(".table-container").handsontable($.extend({
data: def,
data: data,
stretchH: "all"
}, options || {}));
});
......
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