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
7890cb4e
Commit
7890cb4e
authored
May 18, 2018
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json] Replace usage of query by UIDS
parent
c7bfc260
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
33 deletions
+24
-33
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
...portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
+7
-11
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+17
-22
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_callDialogMethod.py
View file @
7890cb4e
...
...
@@ -208,26 +208,22 @@ kw.update(**extra_param)
kw
.
update
(
keep_items
=
extra_param
)
# better backward compatibility
# early-stop if user selected all or too many documents
if
len
(
extra_param
.
get
(
"uids"
,
()))
>=
DOCUMENT_COUNT_LIMIT
or
extra_param
.
get
(
"query"
,
MARKER
)
==
""
:
if
len
(
extra_param
.
get
(
"uids"
,
()))
>=
DOCUMENT_COUNT_LIMIT
:
if
dialog_method
==
update_method
:
pass
# do not interrupt on UPDATE
elif
extra_param
.
get
(
"basedialog_force_submit"
,
0
)
==
0
:
extra_param
[
"basedialog_force_submit"
]
=
1
if
len
(
extra_param
.
get
(
"uids"
,
()))
>=
DOCUMENT_COUNT_LIMIT
:
translated_message
=
translate
(
"Too many documents selected! Submit again to proceed with the first ${limit} or Cancel and narrow down your search."
,
mapping
=
{
'limit'
:
DOCUMENT_COUNT_LIMIT
})
else
:
translated_message
=
translate
(
"All documents are selected! Submit again to proceed or Cancel and narrow down your search."
)
return
context
.
Base_renderForm
(
dialog_id
,
message
=
translated_message
,
message
=
translate
(
"Too many documents selected! Submit again to proceed with the first ${limit} or Cancel and narrow down your search."
,
mapping
=
{
'limit'
:
DOCUMENT_COUNT_LIMIT
}),
level
=
WARNING
,
keep_items
=
extra_param
,
form_data
=
form_data
)
el
if
len
(
extra_param
.
get
(
"uids"
,
()))
>=
DOCUMENT_COUNT_LIMIT
:
#
remove UIDS from the extra_param to force re-computation because the
#
query will be the same but UIDS should change
del
extra_param
[
'uids'
]
el
se
:
#
update UIDS in the extra_param (will get sent back to client and back here)
#
UIDS are already captured in `kw` so dialog action will receive original list
extra_param
[
'uids'
]
=
extra_param
[
'uids'
][
DOCUMENT_COUNT_LIMIT
:
]
# if dialog_category is object_search, then edit the selection
if
dialog_category
==
"object_search"
:
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
7890cb4e
...
...
@@ -1037,16 +1037,23 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
if
form
.
pt
==
"form_dialog"
:
# If there is a "form_id" in the REQUEST then it means that last view was actually a form
# and we are most likely in a dialog. We save previous form into `last_form_id` ...
last_form_id
=
extra_param_json
.
pop
(
"form_id"
,
""
)
or
REQUEST
.
get
(
"form_id"
,
""
)
last_listbox
=
None
# ... so we can do some magic with it (especially embedded listbox if exists)!
try
:
if
last_form_id
:
last_form
=
getattr
(
context
,
last_form_id
)
last_listbox
=
last_form
.
Base_getListbox
()
except
AttributeError
:
pass
# and we are most likely in a dialog. We save previous form into `last_form_id`
last_form_id
=
extra_param_json
.
pop
(
"form_id"
,
""
)
or
REQUEST
.
get
(
"form_id"
,
""
)
or
form
.
id
last_form
=
getattr
(
context
,
last_form_id
)
# So we can support Selections! Yay!
# If extra_param_json already contains necessary arrtibutes: mandatory `query` and optional `uids`
# then our job is done! If not we need to generate them to become parameters for Dialog method.
if
last_form
.
pt
==
"form_list"
:
# on a module-level (form_list page template)
if
"query"
not
in
extra_param_json
:
extra_param_json
[
"query"
]
=
query
# only if Dialog Method specifies UIDS then we generate them into the `extra_param_json`
if
"uids"
not
in
extra_param_json
:
method_args
=
selectKwargsForCallable
(
getattr
(
traversed_document
,
form
.
action
),
{},
{
'uids'
:
None
})
if
"uids"
in
method_args
:
extra_param_json
[
"uids"
]
=
[
int
(
getattr
(
document
,
"uid"
))
for
document
in
traversed_document
.
Base_searchUsingListbox
(
last_form
.
Base_getListbox
(),
extra_param_json
[
"query"
],
limit
=
DOCUMENT_COUNT_LIMIT
)]
REQUEST
.
set
(
"form_id"
,
last_form_id
)
# to be accessible in field rendering (namely ListBox)
# Form traversed_document
...
...
@@ -1101,18 +1108,6 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
# some dialog actions use custom cancel_url
if
REQUEST
.
get
(
'cancel_url'
,
None
):
renderHiddenField
(
response_dict
,
"cancel_url"
,
REQUEST
.
get
(
'cancel_url'
))
# Let's support Selections!
# If extra_param_json already contains necessary arrtibutes: mandatory `query` and optional `uids`
# then our job is done! If not we need to generate them to become parameters for Dialog method.
if
"uids"
not
in
extra_param_json
:
method_args
=
selectKwargsForCallable
(
getattr
(
traversed_document
,
form
.
action
),
{},
{
'uids'
:
None
})
if
"uids"
in
method_args
:
extra_param_json
[
"uids"
]
=
[
int
(
getattr
(
document
,
"uid"
))
for
document
in
traversed_document
.
Base_searchUsingListbox
(
last_listbox
,
query
or
extra_param_json
.
get
(
"query"
,
None
),
limit
=
DOCUMENT_COUNT_LIMIT
)]
if
query
is
not
None
:
extra_param_json
[
"query"
]
=
query
else
:
# In form_view we place only form_id in the request form
renderHiddenField
(
response_dict
,
'form_id'
,
form
.
id
)
...
...
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