@@ -15,19 +15,19 @@ import {
15
15
import {
16
16
forEach ,
17
17
filter ,
18
- isArray ,
19
- isUndefined
18
+ isArray
20
19
} from 'min-dash' ;
21
20
22
21
import * as replaceOptions from '../replace/ReplaceOptions' ;
23
22
24
23
/**
25
- * @typedef {import('../features /BpmnFactory').default } BpmnFactory
24
+ * @typedef {import('../modeling /BpmnFactory').default } BpmnFactory
26
25
* @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default } PopupMenu
27
- * @typedef {import('../features /Modeling').default } Modeling
28
- * @typedef {import('../features /BpmnReplace').default } BpmnReplace
26
+ * @typedef {import('../modeling /Modeling').default } Modeling
27
+ * @typedef {import('../replace /BpmnReplace').default } BpmnReplace
29
28
* @typedef {import('diagram-js/lib/features/Rules').default } Rules
30
29
* @typedef {import('diagram-js/lib/i18n/translate/translate').default } Translate
30
+ * @typedef {import('../copy-paste/ModdleCopy').default } ModdleCopy
31
31
*
32
32
* @typedef {import('../../model/Types').Element } Element
33
33
* @typedef {import('../../model/Types').Moddle } Moddle
@@ -54,10 +54,11 @@ import * as replaceOptions from '../replace/ReplaceOptions';
54
54
* @param {BpmnReplace } bpmnReplace
55
55
* @param {Rules } rules
56
56
* @param {Translate } translate
57
+ * @param {ModdleCopy } moddleCopy
57
58
*/
58
59
export default function ReplaceMenuProvider (
59
60
bpmnFactory , popupMenu , modeling , moddle ,
60
- bpmnReplace , rules , translate ) {
61
+ bpmnReplace , rules , translate , moddleCopy ) {
61
62
62
63
this . _bpmnFactory = bpmnFactory ;
63
64
this . _popupMenu = popupMenu ;
@@ -66,6 +67,7 @@ export default function ReplaceMenuProvider(
66
67
this . _bpmnReplace = bpmnReplace ;
67
68
this . _rules = rules ;
68
69
this . _translate = translate ;
70
+ this . _moddleCopy = moddleCopy ;
69
71
70
72
this . _register ( ) ;
71
73
}
@@ -77,7 +79,8 @@ ReplaceMenuProvider.$inject = [
77
79
'moddle' ,
78
80
'bpmnReplace' ,
79
81
'rules' ,
80
- 'translate'
82
+ 'translate' ,
83
+ 'moddleCopy'
81
84
] ;
82
85
83
86
ReplaceMenuProvider . prototype . _register = function ( ) {
@@ -461,18 +464,24 @@ ReplaceMenuProvider.prototype._getLoopCharacteristicsHeaderEntries = function(ta
461
464
var translate = this . _translate ;
462
465
463
466
function toggleLoopEntry ( event , entry ) {
464
- var newLoopCharacteristics = getBusinessObject ( target ) . loopCharacteristics ;
465
467
468
+ // remove
466
469
if ( entry . active ) {
467
- newLoopCharacteristics = undefined ;
468
- } else {
469
- if ( isUndefined ( entry . options . isSequential ) || ! newLoopCharacteristics
470
- || ! is ( newLoopCharacteristics , entry . options . loopCharacteristics ) ) {
471
- newLoopCharacteristics = self . _moddle . create ( entry . options . loopCharacteristics ) ;
472
- }
470
+ self . _modeling . updateProperties ( target , { loopCharacteristics : undefined } ) ;
471
+ return ;
472
+ }
473
+
474
+ const currentLoopCharacteristics = target . businessObject . get ( ' loopCharacteristics' ) ,
475
+ newLoopCharacteristics = self . _moddle . create ( entry . options . loopCharacteristics ) ;
473
476
474
- newLoopCharacteristics . isSequential = entry . options . isSequential ;
477
+ // copy old properties
478
+ if ( currentLoopCharacteristics ) {
479
+ self . _moddleCopy . copyElement ( currentLoopCharacteristics , newLoopCharacteristics ) ;
475
480
}
481
+
482
+ // update `isSequential` property
483
+ newLoopCharacteristics . set ( 'isSequential' , entry . options . isSequential ) ;
484
+
476
485
self . _modeling . updateProperties ( target , { loopCharacteristics : newLoopCharacteristics } ) ;
477
486
}
478
487
0 commit comments