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
Paul Graydon
erp5
Commits
a5a2f1cd
Commit
a5a2f1cd
authored
Aug 29, 2017
by
Tomáš Peterka
Committed by
Tomáš Peterka
Aug 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5] FormBoxEditor keeps correct context as its attribute
parent
b596deaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
product/ERP5Form/FormBox.py
product/ERP5Form/FormBox.py
+18
-7
No files found.
product/ERP5Form/FormBox.py
View file @
a5a2f1cd
...
@@ -42,6 +42,7 @@ from Products.PythonScripts.standard import url_quote_plus
...
@@ -42,6 +42,7 @@ from Products.PythonScripts.standard import url_quote_plus
from
Products.Formulator.Errors
import
FormValidationError
,
ValidationError
from
Products.Formulator.Errors
import
FormValidationError
,
ValidationError
import
string
import
string
import
copy
class
FormBoxWidget
(
Widget
.
Widget
):
class
FormBoxWidget
(
Widget
.
Widget
):
"""
"""
...
@@ -123,9 +124,15 @@ class FormBoxEditor:
...
@@ -123,9 +124,15 @@ class FormBoxEditor:
"""
"""
A class holding all values required to update the object
A class holding all values required to update the object
"""
"""
def
__init__
(
self
,
field_id
,
result
):
def
__init__
(
self
,
field_id
,
result
,
context
=
None
):
"""Initialize with all necessary information for editing.
Keep a reference to the correct context and don't expect the caller to provide it
during the edit phase because they don't have access to the widget anymore.
"""
self
.
field_id
=
field_id
self
.
field_id
=
field_id
self
.
result
=
result
self
.
attr_dict
,
self
.
editor_list
=
result
self
.
context
=
context
def
view
(
self
):
def
view
(
self
):
return
self
.
__dict__
return
self
.
__dict__
...
@@ -134,8 +141,12 @@ class FormBoxEditor:
...
@@ -134,8 +141,12 @@ class FormBoxEditor:
pass
pass
def
edit
(
self
,
context
):
def
edit
(
self
,
context
):
context
.
edit
(
**
self
.
result
[
0
])
"""Edit inside correct context."""
for
encapsulated_editor
in
self
.
result
[
1
]:
if
self
.
context
is
not
None
:
context
=
self
.
context
context
.
edit
(
**
self
.
attr_dict
)
for
encapsulated_editor
in
self
.
editor_list
:
encapsulated_editor
.
edit
(
context
)
encapsulated_editor
.
edit
(
context
)
def
as_dict
(
self
):
def
as_dict
(
self
):
...
@@ -144,8 +155,8 @@ class FormBoxEditor:
...
@@ -144,8 +155,8 @@ class FormBoxEditor:
XXX This API is probably not stable and may change, as some editors are used to
XXX This API is probably not stable and may change, as some editors are used to
edit multiple objects.
edit multiple objects.
"""
"""
result_dict
=
self
.
result
[
0
]
result_dict
=
copy
.
copy
(
self
.
attr_dict
)
for
encapsulated_editor
in
self
.
result
[
1
]
:
for
encapsulated_editor
in
self
.
editor_list
:
if
hasattr
(
encapsulated_editor
,
'as_dict'
):
if
hasattr
(
encapsulated_editor
,
'as_dict'
):
result_dict
.
update
(
result_dict
.
update
(
encapsulated_editor
.
as_dict
())
encapsulated_editor
.
as_dict
())
...
@@ -181,7 +192,7 @@ class FormBoxValidator(Validator.Validator):
...
@@ -181,7 +192,7 @@ class FormBoxValidator(Validator.Validator):
# XXX Hardcode script name
# XXX Hardcode script name
result
,
result_type
=
here
.
Base_edit
(
formbox_target_id
,
silent_mode
=
1
,
key_prefix
=
key
)
result
,
result_type
=
here
.
Base_edit
(
formbox_target_id
,
silent_mode
=
1
,
key_prefix
=
key
)
if
result_type
==
'edit'
:
if
result_type
==
'edit'
:
return
FormBoxEditor
(
field
.
id
,
result
)
return
FormBoxEditor
(
field
.
id
,
result
,
context
=
here
)
elif
result_type
==
'form'
:
elif
result_type
==
'form'
:
formbox_field_errors
=
REQUEST
.
get
(
'field_errors'
,
[])
formbox_field_errors
=
REQUEST
.
get
(
'field_errors'
,
[])
current_field_errors
.
extend
(
formbox_field_errors
)
current_field_errors
.
extend
(
formbox_field_errors
)
...
...
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