Commit 1cb14e11 authored by Roque's avatar Roque

erp5_officejs: removing eval in handle action (WIP)

parent 58e3545e
......@@ -5,7 +5,7 @@
(function (window, rJS, RSVP) {
"use strict";
var gadget_utils, action_reference, action_type;
var gadget_utils, action_reference, action_type, action_gadget;
rJS(window)
/////////////////////////////////////////////////////////////////
......@@ -44,8 +44,14 @@
.push(function (form_definition) {
if (action_type === "object_jio_js_script") {
if (form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script")) {
// eval must be removed. use loaded action gadget from gadgetfield
action_code = form_definition.fields_raw_properties.gadget_field_action_js_script.values.renderjs_extra[0];
return window.eval.call(window, '(function (gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition, submit_code) {' + action_code[0] + '})')(gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition, action_code[1]);
return form.getDeclaredGadget('gadget_field_action_js_script')
.push(function (declared_gadget) {
action_gadget = declared_gadget;
action_gadget.handleRender(gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition);
});
} else {
throw "Field 'gadget_field_action_js_script' missing in action form. Please check '" + action_reference + "' action configuration.";
}
......@@ -76,7 +82,9 @@
content_dict = options[2],
submit_code = gadget.state.submit_code;
if (action_type === "object_jio_js_script") {
// eval must be removed. use loaded action gadget from gadgetfield
return window.eval.call(window, '(function (gadget, gadget_utils, jio_key, content_dict) {' + submit_code + '})')(gadget, gadget_utils, jio_key, content_dict);
action_gadget.handleSubmit(gadget, gadget_utils, jio_key, content_dict);
}
});
}(window, rJS, RSVP));
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.9050.9155.58845</string> </value>
<value> <string>975.13563.49723.204</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1555685432.75</float>
<float>1555958089.16</float>
<string>UTC</string>
</tuple>
</state>
......
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