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
Eteri
erp5
Commits
f6df3cc2
Commit
f6df3cc2
authored
Aug 29, 2017
by
Tomáš Peterka
Committed by
Eteri
Oct 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ERP5Form] MatrixBox can render itself as a list (JSON friendly)
parent
4e5700a5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
29 deletions
+19
-29
product/ERP5Form/MatrixBox.py
product/ERP5Form/MatrixBox.py
+19
-29
No files found.
product/ERP5Form/MatrixBox.py
View file @
f6df3cc2
...
...
@@ -390,20 +390,16 @@ class MatrixBoxWidget(Widget.Widget):
if
form
.
has_field
(
my_field_id
):
my_field
=
form
.
get_field
(
my_field_id
)
key
=
my_field
.
id
+
'_cell_%s_%s_%s%s'
%
(
i
,
j
,
k
,
extra_dimension_index
)
if
cell
is
not
None
:
attribute_value
=
my_field
.
get_value
(
'default'
,
cell
=
cell
,
cell_index
=
kw
,
cell_position
=
((
i
,
j
,
k
)
+
extra_dimension_position
))
default_value
=
my_field
.
get_value
(
'default'
,
cell
=
cell
,
cell_index
=
kw
,
cell_position
=
((
i
,
j
,
k
)
+
extra_dimension_position
))
display_value
=
default_value
if
field_errors
:
# Display previous value in case of any error in this form because
# we have no cell to get value from
display_value
=
REQUEST
.
get
(
'field_%s'
%
key
,
default_value
)
if
cell
is
not
None
:
if
render_format
==
'html'
:
display_value
=
attribute_value
if
field_errors
:
# Display previous value in case of any error
# in this form because we have no cell to get
# value from
display_value
=
REQUEST
.
get
(
'field_%s'
%
key
,
attribute_value
)
else
:
display_value
=
attribute_value
cell_html
=
my_field
.
render
(
value
=
display_value
,
REQUEST
=
REQUEST
,
key
=
key
)
...
...
@@ -422,23 +418,8 @@ class MatrixBoxWidget(Widget.Widget):
else
:
cell_body
+=
'<span class="input">%s</span>'
%
(
cell_html
)
elif
render_format
==
'list'
:
if
not
my_field
.
get_value
(
'hidden'
):
list_result_lines
.
append
(
attribute_value
)
else
:
attribute_value
=
my_field
.
get_value
(
'default'
,
cell
=
None
,
cell_index
=
kw
,
cell_position
=
((
i
,
j
,
k
)
+
extra_dimension_position
))
if
render_format
==
'html'
:
if
field_errors
:
# Display previous value in case of any error
# in this form because we have no cell to get
# value from
display_value
=
REQUEST
.
get
(
'field_%s'
%
key
,
attribute_value
)
else
:
display_value
=
attribute_value
if
key
in
field_errors
:
# Display error message if this cell has an error
has_error
=
True
...
...
@@ -453,8 +434,17 @@ class MatrixBoxWidget(Widget.Widget):
value
=
display_value
,
REQUEST
=
REQUEST
,
key
=
key
)
elif
render_format
==
'list'
:
list_result_lines
.
append
(
None
)
if
render_format
==
'list'
:
# list rendering doesn't make difference when cell exists or not
list_result_lines
.
append
({
'default'
:
default_value
,
'value'
:
display_value
,
'key'
:
key
,
'type'
:
my_field
.
meta_type
if
my_field
.
meta_type
!=
"ProxyField"
else
my_field
.
getRecursiveTemplateField
().
meta_type
,
'field_id'
:
my_field
.
id
,
'error_text'
:
u"%s"
%
(
translateString
(
field_errors
[
key
].
error_text
)
if
key
in
field_errors
else
''
)
})
css
=
td_css
if
has_error
:
...
...
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