@@ -23,6 +23,8 @@ import {
2323} from '@netgrif/petriflow' ;
2424import { MasterItem } from './classes/master-item' ;
2525import { EventType } from './event-type' ;
26+ import { SequenceGenerator } from '../../services/model/sequence-generator' ;
27+ import { ModelService } from '../../services/model/model.service' ;
2628
2729@Injectable ( {
2830 providedIn : 'root'
@@ -32,18 +34,17 @@ export class ActionEditorService {
3234 public editedActions : Array < ActionGroup > ;
3335 public historySave : boolean ;
3436 private _datarefMap : Map < string , DataRef > ;
35- private _lastUsedId : number ;
3637 private _currentlyEdited : Transition | DataVariable | PetriNet | Role ;
3738
38- constructor ( ) {
39+ constructor (
40+ private _modelService : ModelService ,
41+ ) {
3942 this . editedActions = [ ] ;
40- this . _lastUsedId = 0 ;
4143 this . _datarefMap = new Map < string , DataRef > ( ) ;
4244 }
4345
4446 public nextId ( ) : string {
45- this . _lastUsedId ++ ;
46- return String ( this . _lastUsedId ) ;
47+ return this . _modelService . nextActionId ( ) ;
4748 }
4849
4950 public populateEditedActionsFromTransition ( transition : Transition ) : void {
@@ -116,50 +117,10 @@ export class ActionEditorService {
116117 private loadAction ( action : Action , actionType : ActionType , eventType : EventType , phase : EventPhase , parentDataRefId ?: string ) : EditableAction {
117118 if ( action . id === undefined || action . id === null ) {
118119 action . id = this . nextId ( ) ;
119- } else {
120- this . updateLastId ( action . id ) ;
121120 }
122121 return new EditableAction ( action . id , actionType , false , action . definition , eventType , phase , parentDataRefId ) ;
123122 }
124123
125- private updateLastId ( id : string ) : void {
126- const parsedId = parseInt ( id , 10 ) ;
127- this . _lastUsedId = Math . max ( this . _lastUsedId , isNaN ( parsedId ) ? 0 : parsedId ) ;
128- }
129-
130- public updateIds ( model : PetriNet ) : void {
131- model . getProcessEvents ( ) . forEach ( e => {
132- e . preActions . forEach ( a => this . updateLastId ( a . id ) ) ;
133- e . postActions . forEach ( a => this . updateLastId ( a . id ) ) ;
134- } ) ;
135- model . getCaseEvents ( ) . forEach ( e => {
136- e . preActions . forEach ( a => this . updateLastId ( a . id ) ) ;
137- e . postActions . forEach ( a => this . updateLastId ( a . id ) ) ;
138- } ) ;
139- model . getRoles ( ) . forEach ( r => {
140- r . getEvents ( ) . forEach ( e => {
141- e . preActions . forEach ( a => this . updateLastId ( a . id ) ) ;
142- e . postActions . forEach ( a => this . updateLastId ( a . id ) ) ;
143- } ) ;
144- } ) ;
145- model . getTransitions ( ) . forEach ( t => {
146- t . eventSource . getEvents ( ) . forEach ( e => {
147- e . preActions . forEach ( a => this . updateLastId ( a . id ) ) ;
148- e . postActions . forEach ( a => this . updateLastId ( a . id ) ) ;
149- } ) ;
150- t . dataGroups . forEach ( g => g . getDataRefs ( ) . forEach ( d => d . getEvents ( ) . forEach ( e => {
151- e . preActions . forEach ( a => this . updateLastId ( a . id ) ) ;
152- e . postActions . forEach ( a => this . updateLastId ( a . id ) ) ;
153- } ) ) ) ;
154- } ) ;
155- model . getDataSet ( ) . forEach ( d => {
156- d . getEvents ( ) . forEach ( e => {
157- e . preActions . forEach ( a => this . updateLastId ( a . id ) ) ;
158- e . postActions . forEach ( a => this . updateLastId ( a . id ) ) ;
159- } ) ;
160- } ) ;
161- }
162-
163124 public saveActionChange ( changedAction : EditableAction ) {
164125 this . saveAction ( changedAction ) ;
165126 changedAction . commitChanges ( ) ;
0 commit comments