Commit f774f59f authored by Tomáš Peterka's avatar Tomáš Peterka

[renderjs_ui] Form saves dynamic content only of (editable)fields

parent 199e7247
...@@ -3,12 +3,19 @@ ...@@ -3,12 +3,19 @@
(function (window, rJS, URI, RSVP) { (function (window, rJS, URI, RSVP) {
"use strict"; "use strict";
/** Return local modifications to editable form fields after leaving the form
for a while - for example selecting a related object.
@argument result is possible current field value
*/
function loadFormContent(gadget, result) { function loadFormContent(gadget, result) {
var key; var key;
if (gadget.state.options.form_content) { if (gadget.state.options.form_content) {
for (key in result) { for (key in result) {
if (result.hasOwnProperty(key)) { if (result.hasOwnProperty(key)) {
if (gadget.state.options.form_content[result[key].key]) { if (typeof result[key] === "object" &&
result[key].hasOwnProperty("key") &&
gadget.state.options.form_content[result[key].key]) {
result[key].default = gadget.state.options.form_content[result[key].key]; result[key].default = gadget.state.options.form_content[result[key].key];
} }
} }
......
...@@ -136,12 +136,6 @@ ...@@ -136,12 +136,6 @@
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -163,7 +157,7 @@ ...@@ -163,7 +157,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>romain</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -185,8 +179,8 @@ ...@@ -185,8 +179,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1411464845.21</float> <float>1514233767.52</float>
<string>GMT</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
...@@ -230,7 +224,7 @@ ...@@ -230,7 +224,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.55953.16877.49032</string> </value> <value> <string>964.24685.30142.17664</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +242,7 @@ ...@@ -248,7 +242,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1508331971.69</float> <float>1514478159.1</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -260,61 +254,4 @@ ...@@ -260,61 +254,4 @@
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1411464822.6</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -3,20 +3,6 @@ ...@@ -3,20 +3,6 @@
(function (window, rJS, RSVP, calculatePageTitle) { (function (window, rJS, RSVP, calculatePageTitle) {
"use strict"; "use strict";
function isGoodNonEditableField(field) {
// ListBox and FormBox should always get a chance to render
if (field.type === "ListBox") {return true; }
if (field.type === "FormBox") {return true; }
// hidden fields should not be obviously rendered
if (field.hidden === 1) {return false; }
// field without default
if (!field.default) {return false; }
if (field.default.length === 0) {return false; }
if (field.default.length === 1 && (!field.default[0])) {return false; }
return true;
}
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -64,15 +50,6 @@ ...@@ -64,15 +50,6 @@
rendered_form = gadget.state.erp5_document._embedded._view, rendered_form = gadget.state.erp5_document._embedded._view,
key; key;
// Remove all empty or otherwise bad non-editable fields
for (key in rendered_form) {
if (rendered_form.hasOwnProperty(key) && (key[0] !== "_")) {
if (!isGoodNonEditableField(rendered_form[key])) {
delete rendered_form[key];
}
}
}
form_options.erp5_document = gadget.state.erp5_document; form_options.erp5_document = gadget.state.erp5_document;
form_options.form_definition = gadget.state.form_definition; form_options.form_definition = gadget.state.form_definition;
form_options.view = gadget.state.view; form_options.view = gadget.state.view;
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.35930.39344.6741</string> </value> <value> <string>964.25532.35708.31044</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1507809117.8</float> <float>1514478835.97</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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