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
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
Tomáš Peterka
erp5
Commits
94df7891
Commit
94df7891
authored
Apr 25, 2018
by
Tomáš Peterka
Committed by
Tomáš Peterka
Apr 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json] Support has_changed parameter to Dialog Methods
/reviewed-on
nexedi/erp5!652
parent
8e3cbb95
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
366 additions
and
9 deletions
+366
-9
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_restricted_style/ERP5Document_getHateoas.py
...erp5_hal_json_restricted_style/ERP5Document_getHateoas.py
+1
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_restricted_style/ERP5Document_getHateoas.xml
...rp5_hal_json_restricted_style/ERP5Document_getHateoas.xml
+1
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
...portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
+12
-4
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+9
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
...tal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
+1
-1
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Folder_doNothing.py
...emplateItem/portal_skins/erp5_ui_test/Folder_doNothing.py
+9
-1
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Folder_doNothingDialog.xml
...Item/portal_skins/erp5_ui_test/Folder_doNothingDialog.xml
+3
-1
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Folder_doNothingDialog/custom_variable.xml
...s/erp5_ui_test/Folder_doNothingDialog/custom_variable.xml
+272
-0
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testSelectAll.zpt
...lateItem/portal_tests/renderjs_ui_zuite/testSelectAll.zpt
+48
-1
product/ERP5Form/Form.py
product/ERP5Form/Form.py
+10
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_restricted_style/ERP5Document_getHateoas.py
View file @
94df7891
...
...
@@ -16,6 +16,7 @@ return context.ERP5Document_getHateoas(
select_list
=
select_list
,
limit
=
limit
,
form
=
form
,
form_data
=
form_data
,
relative_url
=
relative_url
,
list_method
=
list_method
,
default_param_json
=
default_param_json
,
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_restricted_style/ERP5Document_getHateoas.xml
View file @
94df7891
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, local_roles=None, form=None, relative_url=None, list_method=None, default_param_json=None, form_relative_url=None, bulk_list="[]", sort_on=None, selection_domain=None, extra_param_json=None, portal_status_message=\'\', portal_status_level=None
</string>
</value>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, local_roles=None, form=None,
form_data=None,
relative_url=None, list_method=None, default_param_json=None, form_relative_url=None, bulk_list="[]", sort_on=None, selection_domain=None, extra_param_json=None, portal_status_message=\'\', portal_status_level=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
View file @
94df7891
...
...
@@ -83,6 +83,7 @@ if dialog_method == 'Folder_delete':
md5_object_uid_list
=
kw
[
'md5_object_uid_list'
])
form
=
getattr
(
context
,
dialog_id
)
form_data
=
None
extra_param
=
json
.
loads
(
extra_param_json
or
"{}"
)
# form can be a python script that returns the form
...
...
@@ -95,7 +96,7 @@ try:
# data. Otherwise, field appears as non editable.
editable_mode
=
request
.
get
(
'editable_mode'
,
1
)
request
.
set
(
'editable_mode'
,
1
)
form
.
validate_all_to_request
(
request
)
form
_data
=
form
.
validate_all_to_request
(
request
)
request
.
set
(
'editable_mode'
,
editable_mode
)
default_skin
=
portal
.
portal_skins
.
getDefaultSkin
()
allowed_styles
=
(
"ODT"
,
"ODS"
,
"Hal"
,
"HalRestricted"
)
...
...
@@ -108,7 +109,8 @@ try:
return
context
.
Base_renderForm
(
dialog_id
,
message
=
translate
(
'Only ODT, ODS, Hal and HalRestricted skins are allowed for reports '
\
'in Preferences - User Interface - Report Style'
),
level
=
WARNING
)
level
=
WARNING
,
form_data
=
form_data
)
except
FormValidationError
as
validation_errors
:
# Pack errors into the request
...
...
@@ -186,7 +188,8 @@ elif query == "" and select_all == 0 and dialog_method != update_method: # do n
message
=
translate
(
"All documents are selected! Submit again to proceed or Cancel and narrow down your search."
),
level
=
WARNING
,
keep_items
=
{
'_select_all'
:
1
},
query
=
query
)
query
=
query
,
form_data
=
form_data
)
# The old way was to set inquire kw for "list_selection_name" and update
# it with kw["uids"] which means a long URL to call this script
...
...
@@ -195,6 +198,11 @@ elif query == "" and select_all == 0 and dialog_method != update_method: # do n
if
dialog_category
==
"object_search"
:
portal
.
portal_selections
.
setSelectionParamsFor
(
kw
[
'selection_name'
],
kw
)
# Notify the underlying script whether user did modifications
form_hash
=
form
.
hash_validated_data
(
form_data
)
if
"form_hash"
in
extra_param
:
kw
[
'has_changed'
]
=
(
form_hash
!=
extra_param
.
pop
(
'form_hash'
))
# Add rest of extra param into arguments of the target method
kw
.
update
(
extra_param
)
...
...
@@ -279,7 +287,7 @@ if True:
meta_type
=
""
if
meta_type
in
(
"ERP5 Form"
,
"ERP5 Report"
):
return
context
.
ERP5Document_getHateoas
(
REQUEST
=
request
,
form
=
dialog_form
,
mode
=
"form"
)
return
context
.
ERP5Document_getHateoas
(
REQUEST
=
request
,
form
=
dialog_form
,
mode
=
"form"
,
form_data
=
form_data
)
return
dialog_form
(
**
kw
)
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
94df7891
...
...
@@ -26,6 +26,10 @@ Parameters for mode == 'search'
Parameters for mode == 'form'
:param form: {instace} of a form - obviously this call can be only internal (Script-to-Script)
:param form_data: {dict} cleaned (validated) form data stored in dict where the key is (prefixed) field.id. We do not use it to
obtain the value of the field because of how the validation itself work. Take a look in
Formulator/Form.validata_all_to_request where REQUEST is modified inplace and in case of first error
an exception is thrown which prevents the return thus form_data are empty in case of partial success.
:param extra_param_json: {dict} extra fields to be added to the rendered form
Parameters for mode == 'traverse'
...
...
@@ -1239,6 +1243,11 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
# end-if report_section
if
form
.
pt
==
"form_dialog"
:
# Insert hash of current values into the form so scripts can see whether data has
# changed if they provide multi-step process
if
form_data
is
not
None
:
extra_param_json
[
"form_hash"
]
=
form
.
hash_validated_data
(
form_data
)
# extra_param_json is a special field in forms (just like form_id). extra_param_json field holds JSON
# metadata about the form (its hash and dynamic fields)
renderHiddenField
(
response_dict
,
'extra_param_json'
,
json
.
dumps
(
extra_param_json
))
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
View file @
94df7891
...
...
@@ -56,7 +56,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, local_roles=None, form=None, relative_url=None, restricted=0, list_method=None, default_param_json=None, form_relative_url=None, bulk_list="[]", sort_on=None, selection_domain=None, extra_param_json=None, portal_status_message=\'\', portal_status_level=None
</string>
</value>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, local_roles=None, form=None,
form_data=None,
relative_url=None, restricted=0, list_method=None, default_param_json=None, form_relative_url=None, bulk_list="[]", sort_on=None, selection_domain=None, extra_param_json=None, portal_status_message=\'\', portal_status_level=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Folder_doNothing.py
View file @
94df7891
...
...
@@ -2,4 +2,12 @@ from Products.ERP5Type.Log import log
log
(
"Folder method received dialog_id, form_id, uids and {!s}"
.
format
(
kwargs
.
keys
()))
return
context
.
Base_redirect
(
form_id
,
keep_items
=
{
"portal_status_message"
:
"Did nothing."
})
if
'has_changed'
not
in
kwargs
or
kwargs
[
'has_changed'
]
is
None
:
message
=
"Did nothing."
else
:
if
kwargs
[
'has_changed'
]:
message
=
"Data has changed."
else
:
message
=
"Data the same."
return
context
.
Base_redirect
(
form_id
,
keep_items
=
{
"portal_status_message"
:
message
})
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Folder_doNothingDialog.xml
View file @
94df7891
...
...
@@ -73,7 +73,9 @@
<item>
<key>
<string>
left
</string>
</key>
<value>
<list/>
<list>
<string>
custom_variable
</string>
</list>
</value>
</item>
<item>
...
...
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Folder_doNothingDialog/custom_variable.xml
0 → 100644
View file @
94df7891
This diff is collapsed.
Click to expand it.
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testSelectAll.zpt
View file @
94df7891
...
...
@@ -68,6 +68,11 @@
<td>
//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[3]/td[1]//p
</td>
<td>
22
</td></tr>
<tr><td>
type
</td>
<td>
//input[@name="field_custom_variable"]
</td>
<td>
couscous
</td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//nav/a[@data-i18n="Next"]
</td><td></td></tr>
<tr><td>
click
</td>
...
...
@@ -86,6 +91,7 @@
<td>
//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[3]/td[1]//p
</td>
<td>
14
</td></tr>
<tr><th
rowspan=
"1"
colspan=
"3"
>
Updating the dialog must not trigger warning about all selected
</th></tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/update_dialog"
/>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
...
...
@@ -100,10 +106,51 @@
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
<tr><td>
type
</td>
<td>
//input[@name="field_custom_variable"]
</td>
<td>
couscous
</td></tr>
<tr><th
rowspan=
"1"
colspan=
"3"
>
Second submission must work as advertised
</th></tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog"
/>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
<tal:block
tal:define=
"notification_configuration python: {'class': 'success', 'text': 'Did nothing.'}"
>
<tal:block
tal:define=
"notification_configuration python: {'class': 'success', 'text': 'Data the same.'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
<tr><th
rowspan=
"1"
colspan=
"3"
>
Let's try has_changed to kick in on simple data change
</th></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//div[@data-role="header"]//a[@data-i18n="Actions"]
</td><td></td></tr>
<tr><td>
click
</td>
<td>
//div[@data-role="header"]//a[@data-i18n="Actions"]
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//ul[@data-role="listview"]//a[@data-i18n="Empty Mass Action"]
</td><td></td></tr>
<tr><td>
click
</td>
<td>
//ul[@data-role="listview"]//a[@data-i18n="Empty Mass Action"]
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//input[@name="field_custom_variable"]
</td><td></td></tr>
<tr><td>
type
</td>
<td>
//input[@name="field_custom_variable"]
</td>
<td>
tajine
</td></tr>
<tr><th
rowspan=
"1"
colspan=
"3"
>
Warn the user and compute form_hash in the background
</th></tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog"
/>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
<tal:block
tal:define=
"notification_configuration python: {'class': 'error', 'text': 'All documents are selected! Submit again to proceed or Cancel and narrow down your search.'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
<tr><td>
waitForElementPresent
</td>
<td>
//input[@name="field_custom_variable"]
</td><td></td></tr>
<tr><td>
type
</td>
<td>
//input[@name="field_custom_variable"]
</td>
<td>
couscous
</td></tr>
<tr><th
rowspan=
"1"
colspan=
"3"
>
Submit BUT pass has_changed true to the dialog method
</th></tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog"
/>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
<tal:block
tal:define=
"notification_configuration python: {'class': 'success', 'text': 'Data has changed.'}"
>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification"
/>
</tal:block>
...
...
product/ERP5Form/Form.py
View file @
94df7891
...
...
@@ -26,6 +26,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
hashlib
from
copy
import
deepcopy
...
...
@@ -766,6 +767,15 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
raise
FormValidationError
(
errors
,
result
)
return
result
security
.
declareProtected
(
'View'
,
'hash_validated_data'
)
def
hash_validated_data
(
self
,
validated_data
):
return
hashlib
.
sha256
(
""
.
join
(
str
(
validated_data
[
key
])
for
key
in
sorted
(
validated_data
.
keys
())
if
isinstance
(
validated_data
[
key
],
(
str
,
unicode
,
int
,
long
,
float
,
DateTime
)))
).
hexdigest
()
# FTP/DAV Access
manage_FTPget
=
ZMIForm
.
get_xml
...
...
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