Commit 28245f7c authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_js_style: add support for dialog

Only basic fields are supported (no gadgetfield for now).
parent 226a4204
<?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>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>dialog_main</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>
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<tal:block metal:define-macro="master">
<tal:block tal:define="
dummy python: request.set('is_web_mode', True);
dummy python: request.set('ignore_layout', False);
dummy python: request.set('editable_mode', True);
dialog_category python: '';
web_site python: here.getWebSiteValue();
web_section python: here.getWebSectionValue();
global_definitions_macros here/global_definitions/macros;">
<tal:block metal:use-macro="global_definitions_macros/header_definitions" />
<html>
<head>
<base tal:attributes="href python: '%s/' % web_section.absolute_url()" />
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1" />
<title tal:content="python: here.getTranslatedTitle() or web_site.getTranslatedTitle()"></title>
<noscript>
<link rel="stylesheet" href="jsstyle.css">
</noscript>
<!-- Prevent conflicts with Web Page reference provided by erp5_web_renderjs_ui -->
<script src="portal_skins/erp5_xhtml_style/rsvp.js"></script>
<script src="portal_skins/erp5_xhtml_style/renderjs.js"></script>
<script src="gadget_global.js"></script>
<script src="jsstyle.js"></script>
</head>
<body tal:attributes="data-nostyle-gadget-url python: web_site.getLayoutProperty('configuration_style_gadget_url', default='')">
<tal:block tal:content="structure python: web_site.WebSite_generateNavigationHTML()"></tal:block>
<main>
<p tal:content="request/portal_status_message | nothing" id="portal_status_message"/>
<tal:block tal:condition="request/field_errors | nothing">
<p id="information_area" i18n:translate="" i18n:domain="ui">
Input data has errors. Please look at the error messages below.
</p>
</tal:block>
<form id="main_form"
tal:attributes="enctype enctype | form/Form_getEnctype | nothing;
action url;
method python:str(path('form/method | string:post')).lower()">
<input type="hidden" name="dialog_method" tal:attributes="value form/action" />
<input type="hidden" name="dialog_id" tal:attributes="value form/id | template/id" />
<tal:block metal:define-slot="main"/>
<button tal:condition="form/action|nothing" accesskey="V"
id="dialog_submit_button" name="Base_callDialogMethod:method"
type="submit">
<span i18n:translate="" i18n:domain="ui"
tal:content="python:here.Base_getFormViewDialogActionButtonTitle(form)">Submit</span>
</button>
</form>
</main>
</body>
</html>
</tal:block>
</tal:block>
</tal:block>
\ No newline at end of file
......@@ -109,6 +109,25 @@
return sitemap;
}
function parseFormElement(form_element) {
var result;
if (form_element !== null) {
return form_element.outerHTML;
}
return result;
}
function parseStatusMessage(status_element, information_element) {
var result = "";
if (status_element !== null) {
result = status_element.textContent;
}
if (information_element !== null) {
result = information_element.textContent;
}
return result;
}
function parsePageContent(body_element) {
return {
html_content: body_element.querySelector('main').innerHTML,
......@@ -117,7 +136,14 @@
),
sitemap: parseSitemapElement(
body_element.querySelector('nav#sitemap')
)
),
form_html_content: parseFormElement(
body_element.querySelector('form#main_form')
),
portal_status_message: parseStatusMessage(
body_element.querySelector('p#portal_status_message'),
body_element.querySelector('p#information_area')
),
};
}
......
......@@ -27,6 +27,8 @@
</head>
<body tal:attributes="data-nostyle-gadget-url python: web_site.getLayoutProperty('configuration_style_gadget_url', default='')">
<tal:block tal:content="structure python: web_site.WebSite_generateNavigationHTML()"></tal:block>
<p tal:content="request/portal_status_message | nothing" id="portal_status_message"/>
<main><tal:block metal:define-slot="main"/></main>
</body>
</html>
......
<?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>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>testJsStyleWebSiteForm</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>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test JS Style Demo Style</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test JS Style Demo Style</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/ERP5Site_createWebJSStyleZuiteTestData?configuration=form</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Web Site created.</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<!-- Initialize -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/erp5_web_js_style_test_site/</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//header/h1[text()='JS Style Demo']</td>
<td></td>
</tr>
<tr>
<td colspan="3"><b>Check the page content uses the web site</b></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//main//form</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//main//form</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='gadget_style_url'][contains(text(), 'erp5_web_js_style_test_site/jsstyle_demo.html')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='render_count'][contains(text(), '1')]</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_id</td>
<td>erp5_web_js_style_test_site</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_title</td>
<td>Demo Form</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//button[@id='dialog_submit_button']//span[text()='Do It']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='portal_status_message' and contains(text(), '')]</td>
<td></td>
</tr>
<tr>
<td colspan="3"><b>Check the form validation</b></td>
</tr>
<tr>
<td>type</td>
<td>field_your_id</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//header/h1[text()='JS Style Demo']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//main//form</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//main//form</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='gadget_style_url'][contains(text(), 'erp5_web_js_style_test_site/jsstyle_demo.html')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='render_count'][contains(text(), '1')]</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_id</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_title</td>
<td>Demo Form</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='portal_status_message' and contains(text(), 'Input data has errors. Please look at the error messages below.')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//span[@class='error' and contains(text(), 'Input is required but no input given.')]</td>
<td></td>
</tr>
<tr>
<td colspan="3"><b>Check the form submission</b></td>
</tr>
<tr>
<td>type</td>
<td>field_your_id</td>
<td>a</td>
</tr>
<tr>
<td>type</td>
<td>field_your_title</td>
<td>b</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//header/h1[text()='JS Style Demo']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//main//form</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//main//form</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='gadget_style_url'][contains(text(), 'erp5_web_js_style_test_site/jsstyle_demo.html')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='render_count'][contains(text(), '1')]</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_id</td>
<td>erp5_web_js_style_test_site</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_title</td>
<td>Demo Form</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='portal_status_message' and contains(text(), 'Submitted a b')]</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//span[@class='error' and contains(text(), 'Input is required but no input given.')]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?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>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>testJsStyleWebSiteNoStyleForm</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>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test JS Style Demo Style</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test JS Style Demo Style</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/ERP5Site_createWebJSStyleZuiteTestData?configuration=nostyleform</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Web Site created.</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<!-- Initialize -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/erp5_web_js_style_test_site/</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>No Style Form</td>
<td></td>
</tr>
<tr>
<td colspan="3"><b>Check the form content</b></td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_id</td>
<td>erp5_web_js_style_test_site</td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_title</td>
<td>No Style Form</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//button[@id='dialog_submit_button']//span[text()='Do It']</td>
<td></td>
</tr>
<tr>
<td colspan="3"><b>Check the form validation</b></td>
</tr>
<tr>
<td>type</td>
<td>field_your_id</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_id</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_title</td>
<td>No Style Form</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='information_area' and contains(text(), 'Input data has errors. Please look at the error messages below.')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='portal_status_message' and contains(text(), '')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//span[@class='error' and contains(text(), 'Input is required but no input given.')]</td>
<td></td>
</tr>
<tr>
<td colspan="3"><b>Check the form submission</b></td>
</tr>
<tr>
<td>type</td>
<td>field_your_id</td>
<td>a</td>
</tr>
<tr>
<td>type</td>
<td>field_your_title</td>
<td>b</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_id</td>
<td>erp5_web_js_style_test_site</td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_title</td>
<td>No Style Form</td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//p[@id='information_area']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//p[@id='portal_status_message' and contains(text(), 'Submitted a b')]</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//span[@class='error' and contains(text(), 'Input is required but no input given.')]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -121,6 +121,10 @@ configuration_dict = {
'nostyle': {
'title': 'No Style'
},
'nostyleform': {
'title': "No Style Form",
'custom_render_method_id': 'WebSite_viewJSStyleTestForm'
},
'section': {
'configuration_style_gadget_url': "jsstyle_demo.html",
'title': "Demo Style",
......@@ -132,7 +136,12 @@ configuration_dict = {
'language': "en",
'aggregate_value': module.restrictedTraverse(web_page_frontend_en_id),
'title': "Demo Style With Language",
}
},
'form': {
'configuration_style_gadget_url': "jsstyle_demo.html",
'title': "Demo Form",
'custom_render_method_id': 'WebSite_viewJSStyleTestForm'
},
}