feat(group-behavior): set copied name value to pasted group elements
Closes camunda/camunda-modeler#1417
This commit is contained in:
parent
e31c4d13ed
commit
9e52e4ee3e
|
@ -145,13 +145,19 @@ export default function GroupBehavior(eventBus, bpmnFactory, canvas, elementRegi
|
||||||
|
|
||||||
var context = event.context,
|
var context = event.context,
|
||||||
shape = context.shape,
|
shape = context.shape,
|
||||||
businessObject = getBusinessObject(shape);
|
businessObject = getBusinessObject(shape),
|
||||||
|
oldBusinessObject = shape.oldBusinessObject;
|
||||||
|
|
||||||
if (is(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
|
if (is(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
|
||||||
|
|
||||||
var definitions = getDefinitions(),
|
var definitions = getDefinitions(),
|
||||||
categoryValue = createCategoryValue(definitions, bpmnFactory);
|
categoryValue = createCategoryValue(definitions, bpmnFactory);
|
||||||
|
|
||||||
|
// set name from copied group if existing
|
||||||
|
if (oldBusinessObject && oldBusinessObject.categoryValueRef) {
|
||||||
|
categoryValue.value = oldBusinessObject.categoryValueRef.value;
|
||||||
|
}
|
||||||
|
|
||||||
// link the reference to the Group
|
// link the reference to the Group
|
||||||
businessObject.categoryValueRef = categoryValue;
|
businessObject.categoryValueRef = categoryValue;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* global sinon */
|
||||||
import {
|
import {
|
||||||
bootstrapModeler,
|
bootstrapModeler,
|
||||||
inject
|
inject
|
||||||
|
@ -11,13 +12,19 @@ import {
|
||||||
indexOf as collectionIndexOf
|
indexOf as collectionIndexOf
|
||||||
} from 'diagram-js/lib/util/Collections';
|
} from 'diagram-js/lib/util/Collections';
|
||||||
|
|
||||||
|
import bpmnCopyPasteModule from 'lib/features/copy-paste';
|
||||||
|
import copyPasteModule from 'diagram-js/lib/features/copy-paste';
|
||||||
import modelingModule from 'lib/features/modeling';
|
import modelingModule from 'lib/features/modeling';
|
||||||
import coreModule from 'lib/core';
|
import coreModule from 'lib/core';
|
||||||
|
|
||||||
|
|
||||||
describe('features/modeling/behavior - groups', function() {
|
describe('features/modeling/behavior - groups', function() {
|
||||||
|
|
||||||
var testModules = [ coreModule, modelingModule ];
|
var testModules = [
|
||||||
|
coreModule,
|
||||||
|
copyPasteModule,
|
||||||
|
bpmnCopyPasteModule,
|
||||||
|
modelingModule ];
|
||||||
|
|
||||||
|
|
||||||
var processDiagramXML = require('./GroupBehaviorSpec.bpmn');
|
var processDiagramXML = require('./GroupBehaviorSpec.bpmn');
|
||||||
|
@ -146,6 +153,46 @@ describe('features/modeling/behavior - groups', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('should set copied name for pasted group', function() {
|
||||||
|
|
||||||
|
it('execute', inject(function(canvas, elementRegistry, copyPaste, eventBus) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var groupShape = elementRegistry.get('Group_1'),
|
||||||
|
categoryValue = getBusinessObject(groupShape).categoryValueRef,
|
||||||
|
root = canvas.getRootElement(),
|
||||||
|
listener = sinon.spy(function(event) {
|
||||||
|
|
||||||
|
var context = event.context,
|
||||||
|
createdElement = context.shape,
|
||||||
|
businessObject = createdElement.businessObject,
|
||||||
|
categoryValueRef = businessObject.categoryValueRef;
|
||||||
|
|
||||||
|
expect(categoryValueRef).to.exist;
|
||||||
|
expect(categoryValueRef).to.not.eql(categoryValue);
|
||||||
|
expect(categoryValueRef.value).to.equal(categoryValue.value);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.on('commandStack.shape.create.postExecute', listener);
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy(groupShape);
|
||||||
|
copyPaste.paste({
|
||||||
|
element: root,
|
||||||
|
point: {
|
||||||
|
x: 50,
|
||||||
|
y: 50
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(listener).to.have.been.called;
|
||||||
|
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue