feat(copy-paste): copy 'fill' and 'stroke' properties

Closes #640
This commit is contained in:
Ricardo Matias 2017-02-03 11:03:50 +01:00 committed by Philipp Fromme
parent 722c86beb2
commit d8098c2feb
2 changed files with 41 additions and 1 deletions

View File

@ -38,7 +38,8 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
var businessObject = getBusinessObject(element), var businessObject = getBusinessObject(element),
newBusinessObject = bpmnFactory.create(businessObject.$type); newBusinessObject = bpmnFactory.create(businessObject.$type);
var properties = getProperties(businessObject.$descriptor); var properties = getProperties(businessObject.$descriptor),
colors = {};
properties = filter(properties, function(property) { properties = filter(properties, function(property) {
return IGNORED_PROPERTIES.indexOf(property.replace(/bpmn:/, '')) === -1; return IGNORED_PROPERTIES.indexOf(property.replace(/bpmn:/, '')) === -1;
@ -50,6 +51,10 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
setProperties(descriptor, businessObject.di, [ 'isExpanded' ]); setProperties(descriptor, businessObject.di, [ 'isExpanded' ]);
setProperties(colors, businessObject.di, [ 'fill', 'stroke' ]);
descriptor.colors = colors;
if (element.type === 'label') { if (element.type === 'label') {
return descriptor; return descriptor;
} }

View File

@ -177,6 +177,41 @@ describe('features/copy-paste', function() {
it('selected elements', inject(integrationTest([ 'SubProcess_1kd6ist' ]))); it('selected elements', inject(integrationTest([ 'SubProcess_1kd6ist' ])));
it('should retain color properties',
inject(function(modeling, copyPaste, canvas, elementRegistry) {
// given
var task = elementRegistry.get('Task_1fo63a7'),
rootElement = canvas.getRootElement(),
newTask,
fill = '#BBDEFB',
stroke = '#1E88E5';
// when
modeling.setColor(task, { fill: fill, stroke: stroke });
copyPaste.copy([ task ]);
copyPaste.paste({
element: rootElement,
point: {
x: 1100,
y: 250
}
});
newTask = elementRegistry.filter(function(element) {
return element.parent === rootElement && element.type === 'bpmn:Task' && element.id !== 'Task_1fo63a7';
})[0];
// then
expect(newTask.type).to.equal('bpmn:Task');
expect(newTask.businessObject.di.fill).to.equal(fill);
expect(newTask.businessObject.di.stroke).to.equal(stroke);
})
);
}); });