Commit 3ee08353 authored by Tomáš Peterka's avatar Tomáš Peterka

[renderjs_ui] Partially revert commit f774f59f with explanation

parent f8215c96
...@@ -3,6 +3,22 @@ ...@@ -3,6 +3,22 @@
(function (window, rJS, RSVP, calculatePageTitle) { (function (window, rJS, RSVP, calculatePageTitle) {
"use strict"; "use strict";
/** Return true if `field` resembles non-empty and non-editable field. */
function isGoodNonEditableField(field) {
// ListBox and FormBox should always get a chance to render because they
// can contain editable fields
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
...@@ -50,6 +66,17 @@ ...@@ -50,6 +66,17 @@
rendered_form = gadget.state.erp5_document._embedded._view, rendered_form = gadget.state.erp5_document._embedded._view,
key; key;
/* Remove empty non-editable fields to prevent them from displaying (business requirement).
Deleting objects inplace does not seem to be a good idea.
*/
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>964.25532.35708.31044</string> </value> <value> <string>964.44232.19748.18107</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>1514478835.97</float> <float>1515406785.95</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