Commit a8470353 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: redirect to first object_view when no view defined

parent 0409ed1f
......@@ -131,6 +131,7 @@
/////////////////////////////////////////////////////////////////\n
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")\n
.declareAcquiredMethod("updateHeader", "updateHeader")\n
.declareAcquiredMethod("redirect", "redirect")\n
\n
/////////////////////////////////////////////////////////////////\n
// declared methods\n
......@@ -146,59 +147,76 @@
element = gadget.props.element,\n
erp5_document,\n
erp5_form,\n
queue,\n
form_gadget;\n
\n
gadget.props.jio_key = options.jio_key;\n
gadget.props.options = options;\n
\n
return gadget.jio_getAttachment(options.jio_key, options.view)\n
queue = gadget.jio_getAttachment(options.jio_key, options.view);\n
queue\n
.push(function (result) {\n
var uri;\n
if (!result._embedded) {\n
return gadget.jio_getAttachment(options.jio_key, "links")\n
.push(function (result) {\n
return gadget.redirect({command: \'change\', options: {\n
view: result._links.view[0].href,\n
editable: undefined,\n
page: undefined\n
}});\n
});\n
}\n
if (options.hasOwnProperty("form_validation_error")) {\n
result._embedded._view = options.form_validation_error;\n
}\n
var uri = new URI(result._embedded._view._links.form_definition.href);\n
uri = new URI(result._embedded._view._links.form_definition.href);\n
erp5_document = result;\n
return gadget.jio_getAttachment(uri.segment(2), "view");\n
})\n
.push(function (result) {\n
erp5_form = result;\n
queue\n
.push(function () {\n
return gadget.jio_getAttachment(uri.segment(2), "view");\n
})\n
.push(function (result) {\n
erp5_form = result;\n
\n
var url = "gadget_erp5_pt_" + erp5_form.pt;\n
// XXX Hardcoded specific behaviour for form_view\n
if ((options.editable !== undefined) && (erp5_form.pt === "form_view")) {\n
url += "_editable";\n
}\n
url += ".html";\n
var url = "gadget_erp5_pt_" + erp5_form.pt;\n
// XXX Hardcoded specific behaviour for form_view\n
if ((options.editable !== undefined) && (erp5_form.pt === "form_view")) {\n
url += "_editable";\n
}\n
url += ".html";\n
\n
return gadget.declareGadget(url, {\n
scope: "fg"\n
});\n
})\n
.push(function (result) {\n
var sub_options = options.fg || {};\n
sub_options.erp5_document = erp5_document;\n
sub_options.form_definition = erp5_form;\n
sub_options.view = options.view;\n
sub_options.action_view = options.action_view;\n
sub_options.jio_key = options.jio_key;\n
sub_options.editable = options.editable;\n
return gadget.declareGadget(url, {\n
scope: "fg"\n
});\n
})\n
.push(function (result) {\n
var sub_options = options.fg || {};\n
sub_options.erp5_document = erp5_document;\n
sub_options.form_definition = erp5_form;\n
sub_options.view = options.view;\n
sub_options.action_view = options.action_view;\n
sub_options.jio_key = options.jio_key;\n
sub_options.editable = options.editable;\n
\n
form_gadget = result;\n
return form_gadget.render(sub_options);\n
})\n
.push(function () {\n
return form_gadget.getElement();\n
})\n
.push(function (fragment) {\n
// Clear first to DOM, append after to reduce flickering/manip\n
while (element.firstChild) {\n
element.removeChild(element.firstChild);\n
}\n
element.appendChild(fragment);\n
if (options.hasOwnProperty("form_validation_error")) {\n
$(element).trigger("create");\n
}\n
form_gadget = result;\n
return form_gadget.render(sub_options);\n
})\n
.push(function () {\n
return form_gadget.getElement();\n
})\n
.push(function (fragment) {\n
// Clear first to DOM, append after to reduce flickering/manip\n
while (element.firstChild) {\n
element.removeChild(element.firstChild);\n
}\n
element.appendChild(fragment);\n
if (options.hasOwnProperty("form_validation_error")) {\n
$(element).trigger("create");\n
}\n
});\n
});\n
return queue;\n
})\n
\n
.allowPublicAcquisition("displayFormulatorValidationError", function (param_list) {\n
......@@ -344,7 +362,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>948.17480.10033.55347</string> </value>
<value> <string>949.26608.26326.12817</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -362,7 +380,7 @@
</tuple>
<state>
<tuple>
<float>1452010103.81</float>
<float>1456489995.58</float>
<string>UTC</string>
</tuple>
</state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<html xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:metal="http://xml.zope.org/namespaces/metal">\n
<head>\n
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n
<title>Test RenderJS UI</title>\n
</head>\n
<body>\n
<table cellpadding="1" cellspacing="1" border="1">\n
<thead>\n
<tr><td rowspan="1" colspan="3">Test RenderJS UI</td></tr>\n
</thead><tbody>\n
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />\n
\n
\n
<tr>\n
<td>open</td>\n
<td>${base_url}/web_site_module/renderjs_runner/#/accounting_module</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>waitForElementPresent</td>\n
<td>//a[@data-i18n=\'Add\']</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>click</td>\n
<td>link=Add</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>waitForElementPresent</td>\n
<td>//button[@data-i18n=\'Proceed\']</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>select</td>\n
<td>//select[@name=\'field_your_portal_type\']</td>\n
<td>label=Sale Invoice Transaction</td>\n
</tr>\n
\n
<tr>\n
<td>click</td>\n
<td>//button[@data-i18n=\'Proceed\']</td>\n
<td></td>\n
</tr>\n
\n
\n
\n
<tr>\n
<td>waitForElementPresent</td>\n
<td>//button[@data-i18n=\'Proceed\']</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>waitForElementPresent</td>\n
<td>//div[@data-gadget-scope="field_my_translated_simulation_state_title"]</td>\n
<td></td>\n
</tr>\n
\n
\n
</tbody></table>\n
</body>\n
</html>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testRedirectWhenNoViewDefined</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -39,6 +39,7 @@ class TestRenderJSUICore(ERP5TypeFunctionalTestCase):
'erp5_web_renderjs_ui',
'erp5_web_renderjs_ui_test',
'erp5_ui_test_core',
'erp5_accounting',
)
def test_suite():
......
erp5_ui_test_core
erp5_ui_test
erp5_web_renderjs_ui
\ No newline at end of file
erp5_web_renderjs_ui
erp5_accounting
\ No newline at end of file
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