Commit 9f65beca authored by Tomáš Peterka's avatar Tomáš Peterka

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

parent 327d936b
...@@ -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];
} }
} }
......
...@@ -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