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
iv
erp5
Commits
8c7e13f1
Commit
8c7e13f1
authored
Aug 25, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: change informations to transmit to jsplumb in Workflow_getGraph
+ separate python script from XML
parent
361e9a77
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
110 deletions
+106
-110
bt5/erp5_graph_editor/SkinTemplateItem/portal_skins/erp5_graph_editor/Workflow_getGraph.py
...eItem/portal_skins/erp5_graph_editor/Workflow_getGraph.py
+106
-0
bt5/erp5_graph_editor/SkinTemplateItem/portal_skins/erp5_graph_editor/Workflow_getGraph.xml
...Item/portal_skins/erp5_graph_editor/Workflow_getGraph.xml
+0
-110
No files found.
bt5/erp5_graph_editor/SkinTemplateItem/portal_skins/erp5_graph_editor/Workflow_getGraph.py
0 → 100644
View file @
8c7e13f1
from
Products.ERP5Type.Message
import
translateString
import
json
portal
=
context
.
getPortalObject
()
# if a graph has been saved, we use this info for node coordinates.
position_graph
=
context
.
getProperty
(
'jsplumb_graph'
)
if
position_graph
:
position_graph
=
json
.
loads
(
position_graph
)[
'graph'
]
# TODO:
# select after script in edge properties
# checked box for validation ? or at least select before script
def
getWorkflowGraph
(
workflow
):
graph
=
{
'node'
:
{},
'edge'
:
{}}
for
state
in
workflow
.
getStateValueList
():
is_initial_state
=
state
.
getId
()
==
workflow
.
getSourceId
()
transition_id_list
=
[]
graph
[
'node'
][
state
.
getId
()]
=
{
'_class'
:
'workflow.state'
,
'name'
:
state
.
getTitleOrId
(),
'is_initial_state'
:
1
if
is_initial_state
else
0
}
for
transition
in
state
.
getDestinationValueList
():
transition_id
=
transition
.
getReference
()
if
transition_id
in
workflow
.
getTransitionIdList
():
if
transition
.
getDestinationId
():
graph
[
'edge'
][
"%s_%s"
%
(
state
.
getId
(),
transition
.
getId
())]
=
(
dict
(
_class
=
'workflow.transition'
,
source
=
state
.
getId
(),
destination
=
transition
.
getDestinationId
(),
name
=
transition
.
getActionName
()
or
transition
.
getTitleOrId
(),
description
=
transition
.
getDescription
(),
actbox_url
=
transition
.
getAction
(),
transition_id
=
transition
.
getId
()
# used for edition.
))
else
:
# user action
transition_id_list
.
append
(
transition_id
)
if
transition_id_list
!=
[]:
for
transition
in
transition_id_list
:
graph
[
'edge'
][
state
.
getId
()]
=
{
'_class'
:
'workflow.transition'
,
'source'
:
state
.
getId
(),
'destination'
:
state
.
getId
(),
'name'
:
str
(
transition_id_list
)
}
if
position_graph
:
for
state_id
in
graph
[
'node'
].
keys
():
if
state_id
in
position_graph
[
'node'
]:
graph
[
'node'
][
state_id
][
'coordinate'
]
=
position_graph
[
'node'
][
state_id
][
'coordinate'
]
return
graph
class_definition
=
{
'workflow.transition'
:
{
'_class'
:
'edge'
,
'type'
:
'object'
,
'description'
:
'A Workflow Transition'
,
'properties'
:
{
'name'
:
{
'type'
:
'string'
,
'name'
:
'Name'
,
'description'
:
'Name of this transition, will be displayed in the document actions'
,
},
'description'
:
{
'type'
:
'string'
,
'name'
:
'Description'
,
},
'actbox_url'
:
{
'type'
:
'string'
,
'name'
:
'Action URL'
,
'description'
:
'URL of the action, variables will be substitued. XXX TODO: higher level ! just configure "script name" '
},
}
},
'workflow.state'
:
{
'_class'
:
'node'
,
'type'
:
'object'
,
'description'
:
'A Workflow State'
,
'properties'
:
{
'name'
:
{
'type'
:
'string'
,
'name'
:
'Name'
,
'description'
:
'The name of the state, will be displayed in document view'
,
},
'id'
:
{
'type'
:
'string'
,
'name'
:
'Id'
,
'description'
:
'Id of the state, will be used for catalog searches'
,
},
'is_initial_state'
:
{
'type'
:
'string'
,
'enum'
:
[
'Yes'
,
'No'
],
'name'
:
'Is initial State'
,
'description'
:
'Set to Yes if this state is the initial state for newly created documents'
,
},
}
}
}
return
json
.
dumps
(
dict
(
graph
=
getWorkflowGraph
(
context
),
class_definition
=
class_definition
),
indent
=
2
)
bt5/erp5_graph_editor/SkinTemplateItem/portal_skins/erp5_graph_editor/Workflow_getGraph.xml
View file @
8c7e13f1
...
...
@@ -48,116 +48,6 @@
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from Products.ERP5Type.Message import translateString\n
import json\n
portal = context.getPortalObject()\n
\n
# if a graph has been saved, we use this info for node coordinates.\n
position_graph = context.getProperty(\'jsplumb_graph\')\n
if position_graph:\n
position_graph = json.loads(position_graph)[\'graph\']\n
\n
# TODO:\n
# select after script in edge properties\n
# checked box for validation ? or at least select before script\n
\n
def getWorkflowGraph(workflow):\n
graph = dict(node=dict(), edge=dict())\n
for state in workflow.getStateValueList():\n
is_initial_state = state.getId() == workflow.getSourceId()\n
transition_id_list = []\n
graph[\'node\'][state.getId()] = dict(\n
_class=\'workflow.state\',\n
name=state.getTitleOrId(),\n
is_initial_state="Yes" if is_initial_state else "No")\n
if is_initial_state:\n
graph[\'node\'][state.getId()][\'css\'] = { "color": "red" } # TODO: use different CSS for initial state\n
\n
for transition in state.getDestinationValueList():\n
transition_id = transition.getReference()\n
if transition_id in workflow.getTransitionIdList():\n
if transition.getDestinationId():\n
graph[\'edge\']["%s_%s" % (state.getId(), transition.getId())] = (\n
dict(_class=\'workflow.transition\',\n
source=state.getId(),\n
destination=transition.getDestinationId(),\n
name=transition.getActionName() or transition.getTitleOrId(),\n
description=transition.getDescription(),\n
actbox_url=transition.getAction(),\n
transition_id=transition.getId() # used for edition.\n
))\n
else:\n
# user action\n
transition_id_list.append(transition_id)\n
\n
if transition_id_list != []:\n
graph[\'edge\'][state.getId()] = (\n
dict(_class=\'workflow.transition\',\n
source=state.getId(),\n
destination=state.getId(),\n
name=str(transition_id_list)\n
))\n
\n
\n
if position_graph:\n
for state_id in graph[\'node\'].keys():\n
if state_id in position_graph[\'node\']:\n
graph[\'node\'][state_id][\'coordinate\'] = position_graph[\'node\'][state_id][\'coordinate\']\n
return graph\n
\n
\n
class_definition = {\n
\'workflow.transition\': {\n
\'_class\': \'edge\',\n
\'type\': \'object\',\n
\'description\': \'A Workflow Transition\',\n
\'properties\': {\n
\'name\': {\n
\'type\': \'string\',\n
\'name\': \'Name\',\n
\'description\': \'Name of this transition, will be displayed in the document actions\',\n
},\n
\'description\': {\n
\'type\': \'string\',\n
\'name\': \'Description\',\n
},\n
\'actbox_url\': {\n
\'type\': \'string\',\n
\'name\': \'Action URL\',\n
\'description\': \'URL of the action, variables will be substitued. XXX TODO: higher level ! just configure "script name" \'\n
},\n
}\n
},\n
\'workflow.state\': {\n
\'_class\': \'node\',\n
\'type\': \'object\',\n
\'description\': \'A Workflow State\',\n
\'properties\': {\n
\'name\': {\n
\'type\': \'string\',\n
\'name\': \'Name\',\n
\'description\': \'The name of the state, will be displayed in document view\',\n
},\n
\'id\': {\n
\'type\': \'string\',\n
\'name\': \'Id\',\n
\'description\': \'Id of the state, will be used for catalog searches\',\n
},\n
\'is_initial_state\': {\n
\'type\': \'string\',\n
\'enum\': [\'Yes\', \'No\'],\n
\'name\': \'Is initial State\',\n
\'description\': \'Set to Yes if this state is the initial state for newly created documents\',\n
},\n
}\n
}\n
}\n
\n
return json.dumps(dict(graph=getWorkflowGraph(context), class_definition=class_definition), indent=2)\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
...
...
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