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

[renderjs_ui] Disable FormBoxes for different context than their parent

parent 1724a5b5
......@@ -459,19 +459,26 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
context_method_id = field.get_value('context_method_id') or None
if context_method_id is not None:
formbox_context = getattr(traversed_document, context_method_id)()
result = {
'type': meta_type,
'title': Base_translateString(field.get_value("title")),
'key': key,
"css_class": field.get_value("css_class"),
"editable": field.get_value("editable"),
'_embedded': {
'_view': {
'_links': {},
'_actions': {},
result = {
"type": meta_type,
"_debug": "FormBox with different Portal Type than its parent are not supported",
"title": Base_translateString(field.get_value("title")),
"key": key,
}
else:
result = {
'type': meta_type,
'title': Base_translateString(field.get_value("title")),
'key': key,
"css_class": field.get_value("css_class"),
"editable": field.get_value("editable"),
'_embedded': {
'_view': {
'_links': {},
'_actions': {},
}
}
}
}
# renderForm mutates `result` therefor no return/assignment
renderForm(formbox_context, embeded_form, result['_embedded']['_view'], key_prefix=key)
# fix editability which is hard-coded to 0 in `renderForm` implementation
......
<!DOCTYPE html>
<html>
<!--
data-i18n=This FormBox is not supported by the backend!
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.7539.6981.40567</string> </value>
<value> <string>961.21935.29137.22101</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1502265124.33</float>
<float>1502445385.24</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -37,6 +37,14 @@
erp5_embedded_document: field_json._embedded
};
// this formbox is not yet supported by the backend
if (erp5_embedded_document === undefined) {
return gadget.translate("This FormBox is not supported by the backend!")
.push(function (message) {
gadget.element.innerHTML = message;
});
}
// prefer editability from the global context (form)
if (options.editable !== undefined) {
new_state.editable = options.editable;
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.17832.13281.59733</string> </value>
<value> <string>961.19210.8471.60620</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1502199696.37</float>
<float>1502444983.84</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