11/* global document, sequentialWorkflowDesigner, console */
22
3- function uid ( ) {
4- return Math . ceil ( Math . random ( ) * 10 ** 16 ) . toString ( 16 ) ;
5- }
6-
7- function createTaskStep ( type , name ) {
3+ function createTaskStep ( id , type , name ) {
84 return {
9- id : uid ( ) ,
5+ id,
106 componentType : 'task' ,
117 type,
128 name,
139 properties : { }
1410 } ;
1511}
1612
17- function createIfStep ( _true , _false ) {
13+ function createIfStep ( id , _true , _false ) {
1814 return {
19- id : uid ( ) ,
15+ id,
2016 componentType : 'switch' ,
2117 type : 'if' ,
2218 name : 'If' ,
@@ -28,9 +24,9 @@ function createIfStep(_true, _false) {
2824 } ;
2925}
3026
31- function createContainerStep ( steps ) {
27+ function createContainerStep ( id , steps ) {
3228 return {
33- id : uid ( ) ,
29+ id,
3430 componentType : 'container' ,
3531 type : 'loop' ,
3632 name : 'Loop' ,
@@ -43,11 +39,11 @@ function toolboxGroup(name) {
4339 return {
4440 name,
4541 steps : [
46- createTaskStep ( 'save' , 'Save file' ) ,
47- createTaskStep ( 'text' , 'Send email' ) ,
48- createTaskStep ( 'task' , 'Create task' ) ,
49- createIfStep ( [ ] , [ ] ) ,
50- createContainerStep ( [ ] )
42+ createTaskStep ( null , 'save' , 'Save file' ) ,
43+ createTaskStep ( null , 'text' , 'Send email' ) ,
44+ createTaskStep ( null , 'task' , 'Create task' ) ,
45+ createIfStep ( null , [ ] , [ ] ) ,
46+ createContainerStep ( null , [ ] )
5147 ]
5248 } ;
5349}
@@ -102,18 +98,18 @@ const configuration = {
10298const startDefinition = {
10399 properties : { } ,
104100 sequence : [
105- createIfStep (
106- [ createTaskStep ( 'save' , 'Save file' ) ] ,
107- [ createTaskStep ( 'text' , 'Send email' ) ]
101+ createIfStep ( '00000000000000000000000000000001' ,
102+ [ createTaskStep ( '00000000000000000000000000000002' , ' save', 'Save file' ) ] ,
103+ [ createTaskStep ( '00000000000000000000000000000003' , ' text', 'Send email' ) ]
108104 ) ,
109- createContainerStep ( [
110- createTaskStep ( 'task' , 'Create task' )
105+ createContainerStep ( '00000000000000000000000000000004' , [
106+ createTaskStep ( '00000000000000000000000000000005' , ' task', 'Create task' )
111107 ] )
112108 ]
113109} ;
114110
115111const placeholder = document . getElementById ( 'designer' ) ;
116112designer = sequentialWorkflowDesigner . create ( placeholder , startDefinition , configuration ) ;
117- designer . onDefinitionChanged . subscribe ( ( ) => {
118- console . log ( 'the definition has changed' ) ;
113+ designer . onDefinitionChanged . subscribe ( ( newDefinition ) => {
114+ console . log ( 'the definition has changed' , newDefinition ) ;
119115} ) ;
0 commit comments