Commit 0f9e1201 authored by Jérome Perrin's avatar Jérome Perrin

Fix field interactions on OfficeJS' New Support Request dialog

Fixes #20200630-BB32 and #20200630-48F9FA

See merge request nexedi/erp5!1318
parents 310e3de0 f5eb9713
Pipeline #12787 failed with stage
......@@ -41,31 +41,37 @@
})
.push(function (hateoas_url) {
gadget.hateoas_url = hateoas_url;
}).push(function () {
gadget.updateResourceListField();
});
})
.declareMethod('triggerSubmit', function () {
return this.form.triggerSubmit();
})
.declareJob('updateResourceListField', function () {
var gadget = this,
selectedProject = document.getElementById('field_your_project').value;
return gadget.jio_getAttachment(
'support_request_module',
gadget.hateoas_url + 'support_request_module'
+ "/SupportRequest_getSupportTypeList"
+ "?project_id=" + selectedProject + "&json_flag=True"
).push(function (sp_list) {
var i, j,
sp_select = document.getElementById('field_your_resource');
for (i = sp_select.options.length - 1; i >= 0; i -= 1) {
sp_select.remove(i);
}
for (j = 0; j < sp_list.length; j += 1) {
sp_select.options[j] = new Option(sp_list[j][0], sp_list[j][1]);
}
});
})
.onEvent('change', function (evt) {
var gadget = this;
if (evt.target.id === "field_your_project") {
var gadget = this;
return gadget.jio_getAttachment(
'support_request_module',
gadget.hateoas_url + 'support_request_module'
+ "/SupportRequest_getSupportTypeList"
+ "?project_id=" + evt.target.value + "&json_flag=True"
).push(function (sp_list) {
var i, j,
sp_select = document.getElementById('field_your_resource');
for (i = sp_select.options.length - 1; i >= 0; i -= 1) {
sp_select.remove(i);
}
for (j = 0; j < sp_list.length; j += 1) {
sp_select.options[j] = new Option(sp_list[j][0], sp_list[j][1]);
}
});
gadget.updateResourceListField();
}
}, false, false);
}(window, rJS));
\ No newline at end of file
......@@ -260,8 +260,8 @@
</tuple>
<state>
<tuple>
<float>1540524000.73</float>
<string>GMT+9</string>
<float>1607511772.31</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
......
......@@ -11,8 +11,8 @@
<value>
<list>
<string>default</string>
<string>first_item</string>
<string>items</string>
<string>required</string>
<string>title</string>
</list>
</value>
......@@ -57,16 +57,14 @@
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
......@@ -74,7 +72,7 @@
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
......@@ -100,10 +98,6 @@
<key> <string>field_id</string> </key>
<value> <string>my_ticket_resource</string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewCRMFieldLibrary</string> </value>
......@@ -123,6 +117,10 @@
</list>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
......@@ -145,7 +143,24 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:[(o.getProperty("title"), o.getProperty("id")) for o in context.getPortalObject().portal_catalog(portal_type="Project", validation_state="validated", select_list=("id", "title"))]</string> </value>
<value> <string encoding="cdata"><![CDATA[
python: len(field.get_value(\'items\') or []) <= 2 and field.get_value(\'items\')[-1][1] or None
]]></string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [("", "")] + [(o.getProperty("title"), o.getProperty("id")) for o in context.getPortalObject().portal_catalog(portal_type="Project", validation_state="validated", select_list=("id", "title"))]</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -10,6 +10,7 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>first_item</string>
<string>items</string>
<string>required</string>
......@@ -55,6 +56,12 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -70,7 +77,7 @@
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
......@@ -92,6 +99,10 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_ticket_resource</string> </value>
......@@ -129,6 +140,23 @@
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[
python: len(field.get_value(\'items\') or []) <= 2 and field.get_value(\'items\')[-1][1] or None
]]></string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
......
<?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>testAddSupportRequestWithMultipleProjectsAvailableForUser</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>
<head>
<title tal:content="template/title">The title</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test adding a support request for users who have access to multiple projects</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_SupportRequestUITemplate/macros/init" />
<tal:block metal:use-macro="here/Zuite_SupportRequestUITemplate/macros/cleanup_module" />
<tal:block metal:use-macro="here/Zuite_SupportRequestUITemplate/macros/create_second_project" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/erp5_officejs_support_request_ui/</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tr>
<td>click</td>
<td>//input[@data-i18n='[value]Submit New Support Request']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>type</td>
<td>//input[@name='field_your_title']</td>
<td>test</td>
</tr>
<!-- When there's more than one project, no project is selected by default -->
<tr>
<td>assertSelectedLabel</td>
<td>field_your_project</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_project"]/option[text() = "RobotMaking"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_project"]/option[text() = "Second Project"]</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>field_your_project</td>
<td>RobotMaking</td>
</tr>
<!-- for RobotMaking project, RequireAssistant is allowed, but BugReport is not -->
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "RequireAssistant"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementNotPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "BugReport"]</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>field_your_project</td>
<td>Second Project</td>
</tr>
<!-- for Second Project project, everything is -->
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "BugReport"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "RequireAssistant"]</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>field_your_resource</td>
<td>FeatureRequire</td>
</tr>
<tal:block tal:define="text_content string:Post test">
<tal:block metal:use-macro="container/Zuite_CommonTemplateForRenderjsUi/macros/type_ckeditor_text_content"/>
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'New Support Request created.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertText</td>
<td>//div[@data-gadget-scope="field_my_source_project_title"]//p</td>
<td>Second Project</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//div[@data-gadget-scope="field_my_resource"]//p</td>
<td>FeatureRequire</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>testAddSupportRequestWithOnlyOneProjectAvailableForUser</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>
<head>
<title tal:content="template/title">The title</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test adding a support request for users who can only access one project</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_SupportRequestUITemplate/macros/init" />
<tal:block metal:use-macro="here/Zuite_SupportRequestUITemplate/macros/cleanup_module" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/erp5_officejs_support_request_ui/</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tr>
<td>click</td>
<td>//input[@data-i18n='[value]Submit New Support Request']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>type</td>
<td>//input[@name='field_your_title']</td>
<td>test</td>
</tr>
<!-- When there's only one project, this project is selected by default -->
<tr>
<td>waitForSelectedLabel</td>
<td>field_your_project</td>
<td>RobotMaking</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "FeatureRequire"]</td>
<td></td>
</tr>
<!-- this default project have a a sale supply line, defining that only FeatureRequire and
RequireAssistant services are available for this project -->
<tr>
<td>waitForElementPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "RequireAssistant"]</td>
<td></td>
</tr>
<!-- other services are not available here. -->
<tr>
<td>waitForElementNotPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "BugReport"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementNotPresent</td>
<td>//select[@name="field_your_resource"]/option[text() = "CrashReport"]</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>field_your_resource</td>
<td>FeatureRequire</td>
</tr>
<tal:block tal:define="text_content string:Post test">
<tal:block metal:use-macro="container/Zuite_CommonTemplateForRenderjsUi/macros/type_ckeditor_text_content"/>
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'New Support Request created.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertText</td>
<td>//div[@data-gadget-scope="field_my_source_project_title"]//p</td>
<td>RobotMaking</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//div[@data-gadget-scope="field_my_resource"]//p</td>
<td>FeatureRequire</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -7,6 +7,9 @@ portal = context.getPortalObject()
test_project_set = set((
portal.project_module.erp5_officejs_support_request_ui_test_project_001,
portal.project_module.erp5_officejs_support_request_ui_test_project_002))
erp5_officejs_support_request_test_second_project = portal.project_module.get('erp5_officejs_support_request_test_second_project')
if erp5_officejs_support_request_test_second_project is not None:
test_project_set.add(erp5_officejs_support_request_test_second_project)
to_delete_list = []
for brain in portal.portal_catalog(
......@@ -20,6 +23,10 @@ for brain in portal.portal_catalog(
to_delete_list.append(support_request.getId())
portal.support_request_module.manage_delObjects(to_delete_list)
if erp5_officejs_support_request_test_second_project is not None:
portal.project_module.manage_delObjects(ids=[erp5_officejs_support_request_test_second_project.getId()])
event_to_delete_id_list = []
for event in portal.event_module.contentValues():
if event.getFollowUp(portal_type='Support Request'):
......
"""Create a second project for support request UI test.
All support request services can be used on this project.
"""
portal = context.getPortalObject()
portal.project_module.newContent(
id='erp5_officejs_support_request_test_second_project',
title='Second Project'
).validate()
return "Done."
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_createSupportRequestUITestSecondProject</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -30,4 +30,12 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
</tal:block>
<tal:block metal:define-macro="create_second_project">
<tr><td>openAndWait</td>
<td>${base_url}/ERP5Site_createSupportRequestUITestSecondProject</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Done.</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
</tal:block>
</tal:block>
\ 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