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 @@ ...@@ -90,6 +90,7 @@
}) })
.push(function (result_list) { .push(function (result_list) {
var content, var content,
i, ctrlflag = true, def = [],
result = JSON.parse(result_list[0]), result = JSON.parse(result_list[0]),
handsontable_options = { handsontable_options = {
minSpareRows: 1, minSpareRows: 1,
...@@ -109,6 +110,21 @@ ...@@ -109,6 +110,21 @@
content = result.input[gadget.props.name]; content = result.input[gadget.props.name];
} else { } else {
content = options.action_definition.configuration.columns; 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 || {}); $.extend(handsontable_options, options.action_definition.configuration.handsontable_options || {});
return result_list[1].render( return result_list[1].render(
......
...@@ -5,28 +5,13 @@ ...@@ -5,28 +5,13 @@
rJS(window) rJS(window)
.declareMethod('render', function (content, options) { .declareMethod('render', function (content, options) {
var data = JSON.parse(content), 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]; }
return this.getElement() return this.getElement()
.push(function (element) { .push(function (element) {
$(element).find('.table-container') $(element).find('.table-container')
.handsontable($.extend({ .handsontable($.extend({
data: def, data: data,
stretchH: 'all' stretchH: 'all'
}, options || {})); }, 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