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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
18e2f507
Commit
18e2f507
authored
Mar 21, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Allow to disable listbox search/sort
parent
e78e5a49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
4 deletions
+82
-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
+4
-4
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+78
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
18e2f507
...
...
@@ -609,14 +609,14 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k
# 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
for
name
,
title
in
(
field
.
get_value
(
"search_columns"
)
or
catalog_column_list
)
if
sql_catalog
.
isValidColumn
(
name
)]
# try to get specified sortable columns and fail back to searchable fields
sort_column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
(
selection_params
.
get
(
'selection_sort_order'
,
[])
or
field
.
get_value
(
"sort_columns"
))
if
sql_catalog
.
isValidColumn
(
name
)]
or
search_column_list
or
field
.
get_value
(
"sort_columns"
)
or
search_column_list
)
if
sql_catalog
.
isValidColumn
(
name
)]
# portal_type list can be overriden by selection too
# since it can be intentionally empty we don't override with non-empty field value
portal_type_list
=
selection_params
.
get
(
"portal_type"
,
field
.
get_value
(
'portal_types'
))
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
18e2f507
...
...
@@ -666,6 +666,84 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
document
.
getRelativeUrl
()))
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_actions'
][
'put'
][
'method'
],
'POST'
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasDocument_disable_listbox_search_column
(
self
):
document
=
self
.
_makeDocument
()
# Disabling search also disable sort if not configured
document
.
Foo_view
.
listbox
.
ListBox_setPropertyList
(
field_title
=
'Foo Lines'
,
field_list_method
=
'objectValues'
,
field_portal_types
=
'Foo Line | Foo Line'
,
field_columns
=
'id|ID
\
n
title|Title
\
n
quantity|Quantity
\
n
start_date|Date
\
n
catalog.uid|Uid'
,
field_search_columns
=
'foo|Foo'
)
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"traverse"
,
relative_url
=
document
.
getRelativeUrl
(),
view
=
"view"
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'column_list'
],
[[
'id'
,
'ID'
],
[
'title'
,
'Title'
],
[
'quantity'
,
'Quantity'
],
[
'start_date'
,
'Date'
],
[
'catalog.uid'
,
'Uid'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'search_column_list'
],
[])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'editable_column_list'
],
[[
'id'
,
'id'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'sort_column_list'
],
[])
# Disabling search does not impact configured sort
document
.
Foo_view
.
listbox
.
ListBox_setPropertyList
(
field_title
=
'Foo Lines'
,
field_list_method
=
'objectValues'
,
field_portal_types
=
'Foo Line | Foo Line'
,
field_columns
=
'id|ID
\
n
title|Title
\
n
quantity|Quantity
\
n
start_date|Date
\
n
catalog.uid|Uid'
,
field_search_columns
=
'foo|Foo'
,
field_sort_columns
=
'title|Title'
)
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"traverse"
,
relative_url
=
document
.
getRelativeUrl
(),
view
=
"view"
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'column_list'
],
[[
'id'
,
'ID'
],
[
'title'
,
'Title'
],
[
'quantity'
,
'Quantity'
],
[
'start_date'
,
'Date'
],
[
'catalog.uid'
,
'Uid'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'search_column_list'
],
[])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'editable_column_list'
],
[[
'id'
,
'id'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'sort_column_list'
],
[[
'title'
,
'Title'
]])
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasDocument_disable_listbox_sort_column
(
self
):
document
=
self
.
_makeDocument
()
document
.
Foo_view
.
listbox
.
ListBox_setPropertyList
(
field_title
=
'Foo Lines'
,
field_list_method
=
'objectValues'
,
field_portal_types
=
'Foo Line | Foo Line'
,
field_columns
=
'id|ID
\
n
title|Title
\
n
quantity|Quantity
\
n
start_date|Date
\
n
catalog.uid|Uid'
,
field_sort_columns
=
'foo|Foo'
)
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"traverse"
,
relative_url
=
document
.
getRelativeUrl
(),
view
=
"view"
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'column_list'
],
[[
'id'
,
'ID'
],
[
'title'
,
'Title'
],
[
'quantity'
,
'Quantity'
],
[
'start_date'
,
'Date'
],
[
'catalog.uid'
,
'Uid'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'search_column_list'
],
[[
'id'
,
'ID'
],
[
'title'
,
'Title'
],
[
'quantity'
,
'Quantity'
],
[
'start_date'
,
'Date'
],
[
'catalog.uid'
,
'Uid'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'editable_column_list'
],
[[
'id'
,
'id'
]])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'sort_column_list'
],
[])
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
...
...
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