@@ -12,7 +12,7 @@ import {
1212
1313import { is } from '../../util/ModelUtil' ;
1414
15- var DISALLOWED_PROPERTIES = [
15+ const DISALLOWED_PROPERTIES = [
1616 'artifacts' ,
1717 'dataInputAssociations' ,
1818 'dataOutputAssociations' ,
@@ -24,7 +24,7 @@ var DISALLOWED_PROPERTIES = [
2424 'categoryValue'
2525] ;
2626
27- var ALLOWED_REFERENCES = [
27+ const ALLOWED_REFERENCES = [
2828 'errorRef' ,
2929 'escalationRef' ,
3030 'messageRef' ,
@@ -52,24 +52,27 @@ export default function ModdleCopy(eventBus, bpmnFactory, moddle) {
5252 this . _moddle = moddle ;
5353
5454 // copy extension elements last
55- eventBus . on ( 'moddleCopy.canCopyProperties' , function ( context ) {
56- var propertyNames = context . propertyNames ;
55+ eventBus . on ( 'moddleCopy.canCopyProperties' , ( context ) => {
56+ const { propertyNames } = context ;
5757
5858 if ( ! propertyNames || ! propertyNames . length ) {
5959 return ;
6060 }
6161
62- return sortBy ( propertyNames , function ( propertyName ) {
62+ return sortBy ( propertyNames , ( propertyName ) => {
6363 return propertyName === 'extensionElements' ;
6464 } ) ;
6565 } ) ;
6666
6767 // default check whether property can be copied
68- eventBus . on ( 'moddleCopy.canCopyProperty' , function ( context ) {
69- var parent = context . parent ,
70- parentDescriptor = isObject ( parent ) && parent . $descriptor ,
71- propertyName = context . propertyName ,
72- property = context . property ;
68+ eventBus . on ( 'moddleCopy.canCopyProperty' , ( context ) => {
69+ const {
70+ parent,
71+ property,
72+ propertyName
73+ } = context ;
74+
75+ const parentDescriptor = isObject ( parent ) && parent . $descriptor ;
7376
7477 if ( propertyName && ALLOWED_REFERENCES . includes ( propertyName ) ) {
7578
@@ -93,8 +96,8 @@ export default function ModdleCopy(eventBus, bpmnFactory, moddle) {
9396 } ) ;
9497
9598 // do NOT allow to copy empty extension elements
96- eventBus . on ( 'moddleCopy.canSetCopiedProperty' , function ( context ) {
97- var property = context . property ;
99+ eventBus . on ( 'moddleCopy.canSetCopiedProperty' , ( context ) => {
100+ const { property } = context ;
98101
99102 if ( is ( property , 'bpmn:ExtensionElements' ) && ( ! property . values || ! property . values . length ) ) {
100103
@@ -121,15 +124,13 @@ ModdleCopy.$inject = [
121124 * @return {ModdleElement }
122125 */
123126ModdleCopy . prototype . copyElement = function ( sourceElement , targetElement , propertyNames , clone = false ) {
124- var self = this ;
125-
126127 if ( propertyNames && ! isArray ( propertyNames ) ) {
127128 propertyNames = [ propertyNames ] ;
128129 }
129130
130131 propertyNames = propertyNames || getPropertyNames ( sourceElement . $descriptor ) ;
131132
132- var canCopyProperties = this . _eventBus . fire ( 'moddleCopy.canCopyProperties' , {
133+ const canCopyProperties = this . _eventBus . fire ( 'moddleCopy.canCopyProperties' , {
133134 propertyNames : propertyNames ,
134135 sourceElement : sourceElement ,
135136 targetElement : targetElement ,
@@ -145,20 +146,20 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
145146 }
146147
147148 // copy properties
148- forEach ( propertyNames , function ( propertyName ) {
149- var sourceProperty ;
149+ forEach ( propertyNames , ( propertyName ) => {
150+ let sourceProperty ;
150151
151152 if ( has ( sourceElement , propertyName ) ) {
152153 sourceProperty = sourceElement . get ( propertyName ) ;
153154 }
154155
155- var copiedProperty = self . copyProperty ( sourceProperty , targetElement , propertyName , clone ) ;
156+ const copiedProperty = this . copyProperty ( sourceProperty , targetElement , propertyName , clone ) ;
156157
157158 if ( ! isDefined ( copiedProperty ) ) {
158159 return ;
159160 }
160161
161- var canSetProperty = self . _eventBus . fire ( 'moddleCopy.canSetCopiedProperty' , {
162+ const canSetProperty = this . _eventBus . fire ( 'moddleCopy.canSetCopiedProperty' , {
162163 parent : targetElement ,
163164 property : copiedProperty ,
164165 propertyName : propertyName
@@ -187,10 +188,9 @@ ModdleCopy.prototype.copyElement = function(sourceElement, targetElement, proper
187188 * @return {any }
188189 */
189190ModdleCopy . prototype . copyProperty = function ( property , parent , propertyName , clone = false ) {
190- var self = this ;
191191
192192 // allow others to copy property
193- var copiedProperty = this . _eventBus . fire ( 'moddleCopy.canCopyProperty' , {
193+ let copiedProperty = this . _eventBus . fire ( 'moddleCopy.canCopyProperty' , {
194194 parent : parent ,
195195 property : property ,
196196 propertyName : propertyName ,
@@ -210,7 +210,7 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clo
210210 return copiedProperty ;
211211 }
212212
213- var propertyDescriptor = this . _moddle . getPropertyDescriptor ( parent , propertyName ) ;
213+ const propertyDescriptor = this . _moddle . getPropertyDescriptor ( parent , propertyName ) ;
214214
215215 // do NOT copy references
216216 if ( propertyDescriptor . isReference ) {
@@ -224,10 +224,10 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clo
224224
225225 // copy arrays
226226 if ( isArray ( property ) ) {
227- return reduce ( property , function ( childProperties , childProperty ) {
227+ return reduce ( property , ( childProperties , childProperty ) => {
228228
229229 // recursion
230- copiedProperty = self . copyProperty ( childProperty , parent , propertyName , clone ) ;
230+ const copiedProperty = this . copyProperty ( childProperty , parent , propertyName , clone ) ;
231231
232232 // copying might NOT be allowed
233233 if ( copiedProperty ) {
@@ -244,12 +244,12 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName, clo
244244 return ;
245245 }
246246
247- copiedProperty = self . _bpmnFactory . create ( property . $type ) ;
247+ copiedProperty = this . _bpmnFactory . create ( property . $type ) ;
248248
249249 copiedProperty . $parent = parent ;
250250
251251 // recursion
252- copiedProperty = self . copyElement ( property , copiedProperty , null , clone ) ;
252+ copiedProperty = this . copyElement ( property , copiedProperty , null , clone ) ;
253253
254254 return copiedProperty ;
255255 }
@@ -276,7 +276,7 @@ ModdleCopy.prototype._copyId = function(id, element, clone = false) {
276276// helpers //////////
277277
278278export function getPropertyNames ( descriptor , keepDefaultProperties ) {
279- return reduce ( descriptor . properties , function ( properties , property ) {
279+ return reduce ( descriptor . properties , ( properties , property ) => {
280280
281281 if ( keepDefaultProperties && property . default ) {
282282 return properties ;
0 commit comments