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
0f26fa07
Commit
0f26fa07
authored
Jul 21, 2017
by
Tomáš Peterka
Committed by
Tomáš Peterka
Jul 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Refactor part of ERP5Document_getHateoas.py to be more readable
parent
42fbcc78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
45 deletions
+25
-45
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+25
-45
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
0f26fa07
...
...
@@ -113,7 +113,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"required"
:
field
.
get_value
(
"required"
),
# XXX Message can not be converted to json as is
"items"
:
field
.
get_value
(
"items"
),
"first_item"
:
field
.
get_value
(
"first_item"
)
"first_item"
:
field
.
get_value
(
"first_item"
)
,
}
result
[
"default"
]
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
],
value
)
elif
meta_type
==
"RadioField"
:
...
...
@@ -342,48 +342,30 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
}
result
[
"default"
]
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
],
value
)
elif
meta_type
==
"ListBox"
:
# XXX Not implemented
column_list
=
[]
for
tmp
in
field
.
get_value
(
"columns"
):
column_list
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
editable_column_list
=
[]
for
tmp
in
field
.
get_value
(
'editable_columns'
):
editable_column_list
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
sort_column_list_tmp
=
[]
for
tmp
in
field
.
get_value
(
'sort_columns'
):
sort_column_list_tmp
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
search_column_list_tmp
=
[]
for
tmp
in
field
.
get_value
(
'search_columns'
):
search_column_list_tmp
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
sort_column_list
=
[]
search_column_list
=
[]
#only get sortable&searchable column which is already displayed in listbox
#see https://lab.nexedi.com/nexedi/erp5/blob/HEAD/product/ERP5Form/ListBox.py#L1004
if
search_column_list_tmp
:
search_column_list
=
search_column_list_tmp
else
:
for
grain
in
column_list
:
if
sql_catalog
.
isValidColumn
(
grain
[
0
]):
search_column_list
.
append
(
grain
)
if
sort_column_list_tmp
:
sort_column_list
=
sort_column_list_tmp
else
:
sort_column_list
=
search_column_list
"""Display list of objects with optional search/sort capabilities on columns from catalog."""
_translate
=
Base_translateString
column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"columns"
)]
editable_column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"editable_columns"
)]
catalog_column_list
=
[(
name
,
title
)
for
name
,
title
in
column_list
if
sql_catalog
.
isValidColumn
(
name
)]
# try to get specified searchable columns and fail back to all searchable columns
search_column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"search_columns"
)
if
sql_catalog
.
isValidColumn
(
name
)]
or
catalog_column_list
# try to get specified sortable columns and fail back to searchable fields
sort_column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"sort_columns"
)
if
sql_catalog
.
isValidColumn
(
name
)]
or
search_column_list
# requirement: get only sortable/searchable columns which are already displayed in listbox
# see https://lab.nexedi.com/nexedi/erp5/blob/HEAD/product/ERP5Form/ListBox.py#L1004
# implemented in javascript in the end
# see https://lab.nexedi.com/nexedi/erp5/blob/master/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.js#L163
# XXX
# list_method = getattr(traversed_document, traversed_document.Listbox_getListMethodName(field))
# portal_types = [x[1] for x in field.get_value('portal_types')]
portal_types
=
field
.
get_value
(
'portal_types'
)
default_params
=
dict
(
field
.
get_value
(
'default_params'
))
default_params
[
'ignore_unknown_columns'
]
=
True
...
...
@@ -445,19 +427,17 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
result
=
{
"type"
:
meta_type
,
"editable"
:
field
.
get_value
(
"editable"
),
# "column_list": [x[1] for x in columns],
"column_list"
:
column_list
,
"search_column_list"
:
search_column_list
,
"sort_column_list"
:
sort_column_list
,
"editable_column_list"
:
editable_column_list
,
"show_anchor"
:
field
.
get_value
(
"anchor"
),
# "line_list": line_list,
"title"
:
Base_translateString
(
field
.
get_value
(
"title"
)),
"key"
:
key
,
"portal_type"
:
portal_types
,
"lines"
:
lines
,
"default_params"
:
default_params
,
"list_method"
:
list_method_name
"list_method"
:
list_method_name
,
}
if
(
list_method_custom
is
not
None
):
result
[
"list_method_template"
]
=
list_method_custom
...
...
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