Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
7c0f804d
Commit
7c0f804d
authored
Jun 10, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Validate dialog before posting it to the server
parent
d751567a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
217 additions
and
75 deletions
+217
-75
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Foo_viewCustomWorkflowRequiredActionDialog/your_custom_workflow_variable.xml
...lowRequiredActionDialog/your_custom_workflow_variable.xml
+1
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
...Item/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
+73
-66
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
...tem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
+2
-2
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflowValidationErrorBackend.xml
...es_zuite/testFormDialogWorkflowValidationErrorBackend.xml
+1
-1
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflowValidationErrorBackend.zpt
...es_zuite/testFormDialogWorkflowValidationErrorBackend.zpt
+79
-0
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflowValidationErrorFrontend.xml
...s_zuite/testFormDialogWorkflowValidationErrorFrontend.xml
+58
-0
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflowValidationErrorFrontend.zpt
...s_zuite/testFormDialogWorkflowValidationErrorFrontend.zpt
+3
-5
No files found.
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Foo_viewCustomWorkflowRequiredActionDialog/your_custom_workflow_variable.xml
View file @
7c0f804d
...
...
@@ -233,7 +233,7 @@
</item>
<item>
<key>
<string>
max_length
</string>
</key>
<value>
<
string></string
>
</value>
<value>
<
int>
50
</int
>
</value>
</item>
<item>
<key>
<string>
required
</string>
</key>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
View file @
7c0f804d
...
...
@@ -35,77 +35,84 @@
}
}
return
getContent
.
apply
(
this
)
.
push
(
function
(
content_dict
)
{
var
data
=
{},
key
;
// create a copy of sub_data so we do not modify them in-place
for
(
key
in
content_dict
)
{
if
(
content_dict
.
hasOwnProperty
(
key
))
{
data
[
key
]
=
content_dict
[
key
];
}
}
// ERP5 expects target Script name in dialog_method field
data
.
dialog_method
=
gadget
.
state
.
form_definition
.
action
;
// For Update Action - override the default value from "action"
if
(
is_updating
)
{
data
.
dialog_method
=
gadget
.
state
.
form_definition
.
update_action
;
data
.
update_method
=
gadget
.
state
.
form_definition
.
update_action
;
}
return
data
;
})
.
push
(
function
(
data
)
{
return
gadget
.
submitContent
(
gadget
.
state
.
jio_key
,
gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
.
put
.
href
,
// most likely points to Base_callDialogMethod
data
);
})
.
push
(
function
(
jio_key
)
{
// success redirect handler
var
splitted_jio_key_list
,
splitted_current_jio_key_list
,
command
,
i
;
if
(
is_updating
||
!
jio_key
)
{
return
checkValidity
.
apply
(
gadget
)
.
push
(
function
(
is_valid
)
{
if
(
!
is_valid
)
{
enableButton
();
return
;
}
if
(
gadget
.
state
.
redirect_to_parent
)
{
return
gadget
.
redirect
({
command
:
'
history_previous
'
});
}
if
(
gadget
.
state
.
jio_key
===
jio_key
)
{
// don't update navigation history when not really redirecting
return
gadget
.
redirect
({
command
:
'
cancel_dialog_with_history
'
});
}
// Check if the redirection goes to a same parent's subdocument.
// In this case, do not add current document to the history
// example: when cloning, do not keep the original document in history
splitted_jio_key_list
=
jio_key
.
split
(
'
/
'
);
splitted_current_jio_key_list
=
gadget
.
state
.
jio_key
.
split
(
'
/
'
);
command
=
'
display_with_history
'
;
if
(
splitted_jio_key_list
.
length
===
splitted_current_jio_key_list
.
length
)
{
for
(
i
=
0
;
i
<
splitted_jio_key_list
.
length
-
1
;
i
+=
1
)
{
if
(
splitted_jio_key_list
[
i
]
!==
splitted_current_jio_key_list
[
i
])
{
return
getContent
.
apply
(
gadget
)
.
push
(
function
(
content_dict
)
{
var
data
=
{},
key
;
// create a copy of sub_data so we do not modify them in-place
for
(
key
in
content_dict
)
{
if
(
content_dict
.
hasOwnProperty
(
key
))
{
data
[
key
]
=
content_dict
[
key
];
}
}
// ERP5 expects target Script name in dialog_method field
data
.
dialog_method
=
gadget
.
state
.
form_definition
.
action
;
// For Update Action - override the default value from "action"
if
(
is_updating
)
{
data
.
dialog_method
=
gadget
.
state
.
form_definition
.
update_action
;
data
.
update_method
=
gadget
.
state
.
form_definition
.
update_action
;
}
return
data
;
})
.
push
(
function
(
data
)
{
return
gadget
.
submitContent
(
gadget
.
state
.
jio_key
,
gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
.
put
.
href
,
// most likely points to Base_callDialogMethod
data
);
})
.
push
(
function
(
jio_key
)
{
// success redirect handler
var
splitted_jio_key_list
,
splitted_current_jio_key_list
,
command
,
i
;
if
(
is_updating
||
!
jio_key
)
{
return
;
}
if
(
gadget
.
state
.
redirect_to_parent
)
{
return
gadget
.
redirect
({
command
:
'
history_previous
'
});
}
if
(
gadget
.
state
.
jio_key
===
jio_key
)
{
// don't update navigation history when not really redirecting
return
gadget
.
redirect
({
command
:
'
cancel_dialog_with_history
'
});
}
// Check if the redirection goes to a same parent's subdocument.
// In this case, do not add current document to the history
// example: when cloning, do not keep the original document in history
splitted_jio_key_list
=
jio_key
.
split
(
'
/
'
);
splitted_current_jio_key_list
=
gadget
.
state
.
jio_key
.
split
(
'
/
'
);
command
=
'
display_with_history
'
;
if
(
splitted_jio_key_list
.
length
===
splitted_current_jio_key_list
.
length
)
{
for
(
i
=
0
;
i
<
splitted_jio_key_list
.
length
-
1
;
i
+=
1
)
{
if
(
splitted_jio_key_list
[
i
]
!==
splitted_current_jio_key_list
[
i
])
{
command
=
'
push_history
'
;
}
}
}
else
{
command
=
'
push_history
'
;
}
}
}
else
{
command
=
'
push_history
'
;
}
// forced document change thus we update history
return
gadget
.
redirect
({
command
:
command
,
options
:
{
"
jio_key
"
:
jio_key
// do not mingle with editable because it isn't necessary
}
});
})
.
push
(
function
(
result
)
{
enableButton
();
return
result
;
// forced document change thus we update history
return
gadget
.
redirect
({
command
:
command
,
options
:
{
"
jio_key
"
:
jio_key
// do not mingle with editable because it isn't necessary
}
});
})
.
push
(
function
(
result
)
{
enableButton
();
return
result
;
});
},
function
(
error
)
{
enableButton
();
throw
error
;
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
View file @
7c0f804d
...
...
@@ -222,7 +222,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
97
2.55890.2478.15121
</string>
</value>
<value>
<string>
97
6.20956.15292.37495
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -240,7 +240,7 @@
</tuple>
<state>
<tuple>
<float>
15
47136935.14
</float>
<float>
15
60246152.37
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflow
Error
.xml
→
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflow
ValidationErrorBackend
.xml
View file @
7c0f804d
...
...
@@ -42,7 +42,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
testFormDialogWorkflow
Error
</string>
</value>
<value>
<string>
testFormDialogWorkflow
ValidationErrorBackend
</string>
</value>
</item>
<item>
<key>
<string>
output_encoding
</string>
</key>
...
...
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflowValidationErrorBackend.zpt
0 → 100644
View file @
7c0f804d
<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 Workflow Transition with Invalid Form
</title>
</head>
<body>
<table
cellpadding=
"1"
cellspacing=
"1"
border=
"1"
>
<thead>
<tr><td
rowspan=
"1"
colspan=
"3"
>
Test Workflow Transition with Invalid Form
</td></tr>
</thead><tbody>
<tal:block
metal:use-macro=
"here/PTZuite_CommonTemplate/macros/init"
/>
<tr>
<td>
open
</td>
<td>
${base_url}/web_site_module/renderjs_runner/#/foo_module/1?editable=1
</td>
<td></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//a[text()='Actions']
</td>
<td></td>
</tr>
<tr>
<td>
click
</td>
<td>
//a[text()='Actions']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//a[@data-i18n='Custom Required Dialog']
</td>
<td></td>
</tr>
<tr>
<td>
click
</td>
<td>
//a[@data-i18n='Custom Required Dialog']
</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
<tr>
<td>
assertElementPresent
</td>
<td>
//input[@name='field_your_custom_workflow_variable']
</td>
<td></td>
</tr>
<tr>
<td>
type
</td>
<td>
//input[@name='field_your_custom_workflow_variable']
</td>
<td>
AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn
</td>
</tr>
<!-- Fill long string to provoke form validation failure -->
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog"
/>
<tal:block
tal:define=
"notification_configuration python: {'class': 'error', 'text': 'Input data has errors.'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
<tr><td>
waitForElementPresent
</td>
<td>
//div[@data-gadget-scope="field_your_custom_workflow_variable"]/div/span
</td><td></td></tr>
<tr><td>
assertText
</td>
<td>
//div[@data-gadget-scope="field_your_custom_workflow_variable"]/div/span
</td>
<td>
Too much input was given.
</td></tr>
<tr><td>
type
</td>
<td>
//textarea[@name='field_your_comment']
</td>
<td>
QWERTY
</td></tr>
<tr><td>
type
</td>
<td>
//input[@name='field_your_custom_workflow_variable']
</td>
<td>
YTREWQ
</td></tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog"
/>
<!-- Wait for the notification to appear. We cannot use verifyText because the button
is there all the time. It gets text assigned and is shown asynchronously later. -->
<tal:block
tal:define=
"notification_configuration python: {'class': 'success', 'text': 'Status changed.'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflowValidationErrorFrontend.xml
0 → 100644
View file @
7c0f804d
<?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>
testFormDialogWorkflowValidationErrorFrontend
</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>
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflow
Error
.zpt
→
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormDialogWorkflow
ValidationErrorFrontend
.zpt
View file @
7c0f804d
...
...
@@ -36,21 +36,19 @@
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
<tr>
<td>
waitFor
ElementPresent
</td>
<td>
assert
ElementPresent
</td>
<td>
//input[@name='field_your_custom_workflow_variable']
</td>
<td></td>
</tr>
<!-- Do not fill anything to provoke form validation failure -->
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog"
/>
<tal:block
tal:define=
"notification_configuration python: {'class': 'error', 'text': 'Input data has errors.'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
<tr><td>
waitForElementPresent
</td>
<td>
//div[@data-gadget-scope="field_your_custom_workflow_variable"]/div/span
</td><td></td></tr>
<tr><td>
assertText
</td>
<td>
//div[@data-gadget-scope="field_your_custom_workflow_variable"]/div/span
</td>
<td>
Input is required but no input given
.
</td></tr>
<td>
Please fill out this field
.
</td></tr>
<tr><td>
type
</td>
<td>
//textarea[@name='field_your_comment']
</td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment