Commit 2c685719 authored by Jérome Perrin's avatar Jérome Perrin

Input_viewSpreadsheet: allow to configure handsontable_options in action definition

parent 3474904a
/*global rJS, RSVP, initGadgetMixin, loopEventListener */ /*global rJS, RSVP, initGadgetMixin, loopEventListener, $ */
(function (window, rJS, RSVP, initGadgetMixin, loopEventListener) { (function (window, rJS, RSVP, initGadgetMixin, loopEventListener, $) {
"use strict"; "use strict";
function saveSpreadsheet(evt) { function saveSpreadsheet(evt) {
...@@ -78,8 +78,6 @@ ...@@ -78,8 +78,6 @@
if (options.action_definition.configuration.input_id){ if (options.action_definition.configuration.input_id){
gadget.props.name = options.action_definition.configuration.input_id; gadget.props.name = options.action_definition.configuration.input_id;
} }
gadget.props.configuration = options.action_definition.configuration;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
...@@ -92,18 +90,9 @@ ...@@ -92,18 +90,9 @@
}) })
.push(function (result_list) { .push(function (result_list) {
var content, var content,
result = JSON.parse(result_list[0]); result = JSON.parse(result_list[0]),
handsontable_options = {
// if there are previously stored data in input for this sprSheet minSpareRows: 1,
if (result.input[gadget.props.name]) {
content = result.input[gadget.props.name];
} else {
content = options.action_definition.configuration.columns;
}
// application_configuration.input.view_???_spreasheet.configuration
return result_list[1].render(
JSON.stringify(content),
{ minSpareRows: 1,
onChange: function () { onChange: function () {
if (gadget.timeout) { if (gadget.timeout) {
window.clearTimeout(gadget.timeout); window.clearTimeout(gadget.timeout);
...@@ -113,7 +102,18 @@ ...@@ -113,7 +102,18 @@
100 100
); );
} }
} };
// if there are previously stored data in input for this sprSheet
if (result.input[gadget.props.name]) {
content = result.input[gadget.props.name];
} else {
content = options.action_definition.configuration.columns;
}
$.extend(handsontable_options, options.action_definition.configuration.handsontable_options || {});
return result_list[1].render(
JSON.stringify(content),
handsontable_options
); );
}); });
}) })
...@@ -128,4 +128,4 @@ ...@@ -128,4 +128,4 @@
]); ]);
}); });
}); });
}(window, rJS, RSVP, initGadgetMixin, loopEventListener)); }(window, rJS, RSVP, initGadgetMixin, loopEventListener, $));
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