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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
486f9bb1
Commit
486f9bb1
authored
Oct 19, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
officejs_support_request_ui: prevent submitting comment twice
parent
73096e57
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
231 additions
and
13 deletions
+231
-13
bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_pt_form_view_discussable_js.js
...dule/gadget_supportrequest_pt_form_view_discussable_js.js
+18
-12
bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_pt_form_view_discussable_js.xml
...ule/gadget_supportrequest_pt_form_view_discussable_js.xml
+1
-1
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testDoubleSubmitComment.xml
...cejs_support_request_ui_zuite/testDoubleSubmitComment.xml
+58
-0
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testDoubleSubmitComment.zpt
...cejs_support_request_ui_zuite/testDoubleSubmitComment.zpt
+154
-0
No files found.
bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_pt_form_view_discussable_js.js
View file @
486f9bb1
...
...
@@ -204,11 +204,10 @@
.
declareJob
(
'
submitPostComment
'
,
function
()
{
var
gadget
=
this
,
submitButton
=
null
,
queue
=
null
,
editor
=
null
;
queue
=
null
;
return
gadget
.
getDeclaredGadget
(
"
editor
"
)
.
push
(
function
(
e
)
{
editor
=
e
;
return
e
.
getContent
();
})
.
push
(
function
(
content
)
{
...
...
@@ -218,8 +217,11 @@
submitButton
=
gadget
.
element
.
querySelector
(
"
input[type=submit]
"
);
submitButton
.
disabled
=
true
;
submitButton
.
classList
.
add
(
"
ui-disabled
"
);
function
enableSubmitButton
()
{
submitButton
.
disabled
=
false
;
submitButton
.
classList
.
remove
(
"
ui-disabled
"
);
}
queue
=
gadget
.
notifySubmitted
({
message
:
"
Posting comment
"
})
.
push
(
function
()
{
...
...
@@ -231,6 +233,10 @@
data
.
append
(
"
predecessor
"
,
''
);
data
.
append
(
"
data
"
,
content
.
comment
);
data
.
append
(
"
file
"
,
file_blob
);
// reset the file upload, otherwise next comment would upload same file again
choose_file_html_element
.
value
=
""
;
// XXX: Hack, call jIO.util.ajax directly to pass the file blob
// Because the jio_putAttachment will call readBlobAsText, which
// will broke the binary file. Call the jIO.util.ajax directly
...
...
@@ -245,15 +251,15 @@
});
})
.
push
(
function
()
{
return
gadget
.
notifySubmitted
({
message
:
"
Comment added
"
,
status
:
"
success
"
});
})
.
push
(
function
()
{
editor
.
changeState
({
value
:
''
})
.
push
(
function
()
{
return
new
RSVP
.
Queue
().
push
(
function
()
{
gadget
.
notifySubmitted
({
message
:
"
Comment added
"
,
status
:
"
success
"
});
}).
push
(
function
()
{
return
gadget
.
redirect
({
command
:
'
reload
'
});
});
},
function
(
e
)
{
enableSubmitButton
();
return
gadget
.
notifySubmitted
({
message
:
"
Error:
"
+
e
,
status
:
"
error
"
});
});
queue
.
push
(
enableSubmitButton
,
enableSubmitButton
);
return
queue
;
});
})
...
...
@@ -266,6 +272,6 @@
);
},
5000
)
.
onEvent
(
'
submit
'
,
function
()
{
this
.
submitPostComment
();
return
this
.
submitPostComment
();
});
}(
window
,
rJS
,
RSVP
,
calculatePageTitle
,
moment
,
Handlebars
));
\ No newline at end of file
bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_pt_form_view_discussable_js.xml
View file @
486f9bb1
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
15399
39405.65
</float>
<float>
15399
46621.33
</float>
<string>
GMT+9
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testDoubleSubmitComment.xml
0 → 100644
View file @
486f9bb1
<?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>
testDoubleSubmitComment
</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_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testDoubleSubmitComment.zpt
0 → 100644
View file @
486f9bb1
<html>
<head>
<title
tal:content=
"template/title_or_id"
>
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"
>
Support Request Zuite
</td></tr>
</thead><tbody>
<tal:block
metal:use-macro=
"here/Zuite_SupportRequestUITemplate/macros/init"
/>
<tr>
<td>
open
</td>
<td>
${base_url}/web_site_module/erp5_officejs_support_request_ui/
</td>
<td></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//input[@data-i18n='[value]Submit New Support Request']
</td>
<td></td>
</tr>
<tr>
<td>
click
</td>
<td>
//input[@data-i18n='[value]Submit New Support Request']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//input[@data-i18n="[value]Proceed"]
</td>
<td></td>
</tr>
<tr>
<td>
type
</td>
<td>
//input[@name='field_your_title']
</td>
<td>
test
</td>
</tr>
<tr>
<td>
select
</td>
<td>
field_your_project
</td>
<td>
RobotMaking
</td>
</tr>
<tr>
<td>
waitForTextPresent
</td>
<td>
FeatureRequire
</td>
<td></td>
</tr>
<tr>
<td>
select
</td>
<td>
field_your_resource
</td>
<td>
FeatureRequire
</td>
</tr>
<tal:block
tal:define=
"text_content string:First Post Content"
>
<tal:block
metal:use-macro=
"container/Zuite_CommonTemplateForRenderjsUi/macros/type_ckeditor_text_content"
/>
</tal:block>
<tr>
<td>
waitForElementPresent
</td>
<td>
//input[@data-i18n='[value]Proceed']
</td>
<td></td>
</tr>
<tr>
<td>
click
</td>
<td>
//input[@data-i18n='[value]Proceed']
</td>
<td></td>
</tr>
<tr>
<td>
waitForText
</td>
<td>
//ol[@id="post_list"]//li[1]/p
</td>
<td>
First Post Content
</td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//input[@data-i18n="[value]Post Comment"]
</td>
<td></td>
</tr>
<tal:block
tal:define=
"text_content string:Second Post Content"
>
<tal:block
metal:use-macro=
"container/Zuite_CommonTemplateForRenderjsUi/macros/type_ckeditor_text_content"
/>
</tal:block>
<tr>
<td>
click
</td>
<td>
//input[@data-i18n='[value]Post Comment']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//input[@data-i18n='[value]Post Comment' and @disabled and contains(@class, "ui-disabled")]
</td>
<td></td>
</tr>
<tal:block
tal:define=
"notification_configuration python: {'class': 'success',
'text': 'Comment added'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
<tr>
<td>
click
</td>
<td>
//input[@data-i18n='[value]Post Comment']
</td>
<td></td>
</tr>
<tr>
<td>
click
</td>
<td>
//input[@data-i18n='[value]Post Comment']
</td>
<td></td>
</tr>
<tr>
<td>
click
</td>
<td>
//input[@data-i18n='[value]Post Comment']
</td>
<td></td>
</tr>
<tr>
<td>
store
</td>
<td>
javascript{selenium.browserbot.getCurrentWindow().location.href}
</td>
<td>
current_location
</td>
</tr>
<tr>
<td>
open
</td>
<td
tal:content=
"string:${here/portal_url}/Zuite_waitForActivities"
/>
<td/>
</tr>
<tr>
<td>
waitForTextPresent
</td>
<td>
Done.
</td>
<td/>
</tr>
<tr>
<td>
open
</td>
<td>
${current_location}
</td>
<td></td>
</tr>
<!-- The second post was submitted only once. -->
<tr>
<td>
waitForText
</td>
<td>
//ol[@id="post_list"]//li[1]/p
</td>
<td>
First Post Content
</td>
</tr>
<tr>
<td>
waitForText
</td>
<td>
//ol[@id="post_list"]//li[2]/p
</td>
<td>
Second Post Content
</td>
</tr>
<tr>
<td>
assertElementNotPresent
</td>
<td>
//ol[@id="post_list"]//li[3]/p
</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
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