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
Yusei Tahara
erp5
Commits
d0c7d5ee
Commit
d0c7d5ee
authored
May 04, 2018
by
Tomáš Peterka
Committed by
Tomáš Peterka
May 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json] Introduce new action category *_onlyjio_*
parent
dbcaa640
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
238 additions
and
0 deletions
+238
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_filterDuplicateActions.py
..._skins/erp5_hal_json_style/Base_filterDuplicateActions.py
+91
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_filterDuplicateActions.xml
...skins/erp5_hal_json_style/Base_filterDuplicateActions.xml
+62
-0
product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_categories/action_type/object_onlyjio_action.xml
...m/portal_categories/action_type/object_onlyjio_action.xml
+85
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_filterDuplicateActions.py
0 → 100644
View file @
d0c7d5ee
"""This script is MANDATORY to use to filter out duplicate/incompatible actions for a document.
Duplicate actions are actions with the same ID in the same action category or related XHTML category.
In case of duplicate, the JIO version (or the first in the same category) will be kept.
In the ideal state - this would return only categories named "object_action", "object_view" without
any infixes. This would remove logic from templates and the would not need to know about "_jio_"
actions and others possibly introduced in the future.
`actions` is the mapping returned by ActionsTool.listFilteredActionsFor
The script must be called on the context of the document.
"""
from
Products.ERP5Type.Cache
import
CachingMethod
def
filterActions
(
actions
):
"""Reorganise and rename action categories for templates so they do not need to contain any logic."""
filtered_actions
=
{}
for
action_category_name
,
action_list
in
actions
.
items
():
# action category _onlyjio_ contains actions shown only in RenderJS interface
# we hide this detail from templates because they should not contain any logic
if
"_onlyjio_"
in
action_category_name
:
action_category_name
=
action_category_name
.
replace
(
"_onlyjio_"
,
"_jio_"
)
if
action_category_name
in
filtered_actions
:
filtered_actions
[
action_category_name
].
extend
(
action_list
)
else
:
filtered_actions
[
action_category_name
]
=
action_list
return
filtered_actions
def
filterDuplicateActions
(
actions
):
new_actions
=
{}
for
action_category_name
,
action_list
in
actions
.
items
():
new_actions
.
setdefault
(
action_category_name
,
{})
# with introduction of the new UI some actions can have JIO only versions
# so we have to consider them as duplicates even though they are in different
# category because those categories are rendered together (e.g object_action and object_jio_action)
is_jio_action_category
=
"_jio_"
in
action_category_name
# we could if not is_jio_action_category: continue ...
other_action_id_set
=
set
()
if
is_jio_action_category
:
prefix
,
_
,
suffix
=
action_category_name
.
split
(
"_"
,
2
)
# omit the _jio_
other_action_id_set
.
update
(
action
[
'id'
]
for
action
in
actions
.
get
(
prefix
+
"_"
+
suffix
,
[]))
else
:
if
"_"
in
action_category_name
:
prefix
,
suffix
=
action_category_name
.
split
(
"_"
,
1
)
other_action_id_set
.
update
(
action
[
'id'
]
for
action
in
actions
.
get
(
prefix
+
"_jio_"
+
suffix
,
[]))
for
action
in
action_list
:
if
not
is_jio_action_category
:
# prefer JIO version of the same action
if
action
[
'id'
]
in
other_action_id_set
:
continue
if
action
[
'id'
]
not
in
new_actions
[
action_category_name
]:
new_actions
[
action_category_name
][
action
[
'id'
]]
=
action
# return dict[str: list] of category_name: sorted list of contained actions
# global actions do not have priority so we give them 1.0 by default
return
{
action_category_name
:
sorted
(
action_dict
.
values
(),
key
=
lambda
x
:
x
.
get
(
'priority'
,
1.0
))
for
action_category_name
,
action_dict
in
new_actions
.
items
()}
def
hasJIODuplicateActions
(
portal_type
,
user_name
):
len_actions
=
0
len_filtered_actions
=
0
for
cat
in
actions
.
values
():
len_actions
+=
len
(
cat
)
filtered_actions
=
filterDuplicateActions
(
actions
)
for
cat
in
filtered_actions
.
values
():
len_filtered_actions
+=
len
(
cat
)
return
len_actions
!=
len_filtered_actions
hasDuplicateActions
=
CachingMethod
(
hasJIODuplicateActions
,
id
=
'Base_filterDuplicateActions.hasJIODuplicateActions'
,
cache_factory
=
'erp5_ui_long'
)
actions
=
filterActions
(
actions
)
user_name
=
getattr
(
container
.
REQUEST
,
'AUTHENTICATED_USER'
,
''
)
if
getattr
(
context
,
'getPortalType'
,
None
)
is
not
None
:
if
hasDuplicateActions
(
context
.
getPortalType
(),
user_name
):
return
filterDuplicateActions
(
actions
)
return
actions
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_filterDuplicateActions.xml
0 → 100644
View file @
d0c7d5ee
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
actions
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_filterDuplicateActions
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_categories/action_type/object_onlyjio_action.xml
0 → 100644
View file @
d0c7d5ee
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Category"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_Add_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Add_portal_folders_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Copy_or_Move_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Delete_objects_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Modify_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_onlyjio_action
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
object_onlyjio_action
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Category
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
object_onlyjio_action
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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