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

Fix initialisation of spreadsheet, 24d7df81 introduced a regression

parent 9bff0a69
......@@ -90,6 +90,7 @@
})
.push(function (result_list) {
var content,
i, ctrlflag = true, def = [],
result = JSON.parse(result_list[0]),
handsontable_options = {
minSpareRows: 1,
......@@ -109,6 +110,21 @@
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(
......
......@@ -5,28 +5,13 @@
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