mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 17:44:12 +00:00
chore(modeling): rename Modeling#move{Shapes->Elements}
Related to bpmn-io/diagram-js#107 BREAKING CHANGE: * Modeling#moveShapes got renamed to Modeling#moveElements * Id of command changed from 'shapes.move' to 'elements.move'
This commit is contained in:
parent
8e4d58b5ce
commit
3cb1721c89
@ -75,7 +75,7 @@ function CreateParticipantBehavior(eventBus, modeling, elementFactory, bpmnFacto
|
|||||||
if (processRoot) {
|
if (processRoot) {
|
||||||
// process root is already detached at this point
|
// process root is already detached at this point
|
||||||
var processChildren = processRoot.children.slice();
|
var processChildren = processRoot.children.slice();
|
||||||
modeling.moveShapes(processChildren, { x: 0, y: 0 }, shape);
|
modeling.moveElements(processChildren, { x: 0, y: 0 }, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -30,7 +30,7 @@ function MoveStartEventBehavior(eventBus, bpmnReplace) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.postExecuted([ 'shapes.move' ], function(event) {
|
this.postExecuted([ 'elements.move' ], function(event) {
|
||||||
|
|
||||||
var target = event.context.newParent;
|
var target = event.context.newParent;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.postExecuted('shapes.move', function(context) {
|
this.postExecuted('elements.move', function(context) {
|
||||||
|
|
||||||
var closure = context.closure,
|
var closure = context.closure,
|
||||||
allConnections = closure.allConnections;
|
allConnections = closure.allConnections;
|
||||||
|
@ -70,7 +70,7 @@ BpmnRules.prototype.init = function() {
|
|||||||
return canResize(shape, newBounds);
|
return canResize(shape, newBounds);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addRule('shapes.move', function(context) {
|
this.addRule('elements.move', function(context) {
|
||||||
|
|
||||||
var target = context.target,
|
var target = context.target,
|
||||||
shapes = context.shapes,
|
shapes = context.shapes,
|
||||||
|
@ -43,7 +43,7 @@ describe('features/move - drop', function() {
|
|||||||
parent = elementRegistry.get('ID_SubProcess_1');
|
parent = elementRegistry.get('ID_SubProcess_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ task_1, task_2 ], { x: 0, y: 200 }, parent);
|
modeling.moveElements([ task_1, task_2 ], { x: 0, y: 200 }, parent);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(task_1.parent).to.eql(parent);
|
expect(task_1.parent).to.eql(parent);
|
||||||
@ -69,7 +69,7 @@ describe('features/move - drop', function() {
|
|||||||
flow = elementRegistry.get('ID_Sequenceflow_1');
|
flow = elementRegistry.get('ID_Sequenceflow_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ task_1 ], { x: 0, y: 200 }, parent);
|
modeling.moveElements([ task_1 ], { x: 0, y: 200 }, parent);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(flow.parent).to.be.null;
|
expect(flow.parent).to.be.null;
|
||||||
@ -86,7 +86,7 @@ describe('features/move - drop', function() {
|
|||||||
flow = elementRegistry.get('ID_Sequenceflow_1');
|
flow = elementRegistry.get('ID_Sequenceflow_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ task_1, task_2 ], { x: 0, y: 250 }, parent);
|
modeling.moveElements([ task_1, task_2 ], { x: 0, y: 250 }, parent);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(flow.parent).to.eql(parent);
|
expect(flow.parent).to.eql(parent);
|
||||||
@ -108,7 +108,7 @@ describe('features/move - drop', function() {
|
|||||||
sequenceFlow = elementRegistry.get('ID_sequenceflow_1');
|
sequenceFlow = elementRegistry.get('ID_sequenceflow_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ task_1 ], { x: 0, y: 200 }, parent);
|
modeling.moveElements([ task_1 ], { x: 0, y: 200 }, parent);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(task_1.parent).to.eql(parent);
|
expect(task_1.parent).to.eql(parent);
|
||||||
|
@ -212,7 +212,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ startEventElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement ], { x: 40, y: -80 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(label.x).to.equal(labelPosition.x + 40);
|
expect(label.x).to.equal(labelPosition.x + 40);
|
||||||
@ -233,7 +233,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(flowLabel.x).to.equal(labelPosition.x + 40);
|
expect(flowLabel.x).to.equal(labelPosition.x + 40);
|
||||||
@ -255,7 +255,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
y: label.y
|
y: label.y
|
||||||
};
|
};
|
||||||
|
|
||||||
modeling.moveShapes([ startEventElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement ], { x: 40, y: -80 });
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
@ -278,7 +278,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
y: flowLabel.y
|
y: flowLabel.y
|
||||||
};
|
};
|
||||||
|
|
||||||
modeling.moveShapes([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
@ -305,7 +305,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
y: label.y
|
y: label.y
|
||||||
};
|
};
|
||||||
|
|
||||||
modeling.moveShapes([ startEventElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement ], { x: 40, y: -80 });
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -329,7 +329,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
y: flowLabel.y
|
y: flowLabel.y
|
||||||
};
|
};
|
||||||
|
|
||||||
modeling.moveShapes([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -130,7 +130,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
targetShape = element('Participant_2');
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ taskShape ], { x: 0, y: 330 }, targetShape);
|
modeling.moveElements([ taskShape ], { x: 0, y: 330 }, targetShape);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(taskShape.parent).to.eql(targetShape);
|
expect(taskShape.parent).to.eql(targetShape);
|
||||||
@ -149,7 +149,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
targetShape = element('Participant_2'),
|
targetShape = element('Participant_2'),
|
||||||
oldParent = taskShape.parent;
|
oldParent = taskShape.parent;
|
||||||
|
|
||||||
modeling.moveShapes([ taskShape ], { x: 0, y: 300 }, targetShape);
|
modeling.moveElements([ taskShape ], { x: 0, y: 300 }, targetShape);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
@ -176,7 +176,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
targetShape = element('Participant_2');
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ startEventShape, taskShape ], { x: 0, y: 330 }, targetShape);
|
modeling.moveElements([ startEventShape, taskShape ], { x: 0, y: 330 }, targetShape);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(taskShape.parent).to.eql(targetShape);
|
expect(taskShape.parent).to.eql(targetShape);
|
||||||
@ -196,7 +196,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
targetShape = element('Participant_2'),
|
targetShape = element('Participant_2'),
|
||||||
oldParent = taskShape.parent;
|
oldParent = taskShape.parent;
|
||||||
|
|
||||||
modeling.moveShapes([ taskShape ], { x: 0, y: 300 }, targetShape);
|
modeling.moveElements([ taskShape ], { x: 0, y: 300 }, targetShape);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
@ -224,7 +224,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
targetShape = element('Participant_2');
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ subProcessShape ], { x: 0, y: 530 }, targetShape);
|
modeling.moveElements([ subProcessShape ], { x: 0, y: 530 }, targetShape);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(subProcessShape.parent).to.eql(targetShape);
|
expect(subProcessShape.parent).to.eql(targetShape);
|
||||||
@ -241,7 +241,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
var subProcessShape = element('SubProcess_1'),
|
var subProcessShape = element('SubProcess_1'),
|
||||||
targetShape = element('Participant_2');
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
modeling.moveShapes([ subProcessShape ], { x: 0, y: 530 }, targetShape);
|
modeling.moveElements([ subProcessShape ], { x: 0, y: 530 }, targetShape);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
@ -282,7 +282,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
targetShape = element('Participant_1');
|
targetShape = element('Participant_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ textAnnotationShape ], { x: -200, y: 40 }, targetShape);
|
modeling.moveElements([ textAnnotationShape ], { x: -200, y: 40 }, targetShape);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(textAnnotationShape.parent).to.eql(targetShape);
|
expect(textAnnotationShape.parent).to.eql(targetShape);
|
||||||
@ -297,7 +297,7 @@ describe('features/modeling - replace connection', function() {
|
|||||||
var textAnnotationShape = element('TextAnnotation_1'),
|
var textAnnotationShape = element('TextAnnotation_1'),
|
||||||
targetShape = element('Participant_1');
|
targetShape = element('Participant_1');
|
||||||
|
|
||||||
modeling.moveShapes([ textAnnotationShape ], { x: -200, y: 40 }, targetShape);
|
modeling.moveElements([ textAnnotationShape ], { x: -200, y: 40 }, targetShape);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
@ -46,7 +46,7 @@ function move(shape, delta) {
|
|||||||
// assume
|
// assume
|
||||||
expect(shapeElement).to.exist;
|
expect(shapeElement).to.exist;
|
||||||
|
|
||||||
modeling.moveShapes([shapeElement], delta);
|
modeling.moveElements([shapeElement], delta);
|
||||||
|
|
||||||
return shapeElement;
|
return shapeElement;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ describe('features/modeling - layout message flows', function() {
|
|||||||
messageFlowConnection = elementRegistry.get('MessageFlow_4');
|
messageFlowConnection = elementRegistry.get('MessageFlow_4');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ taskShape ], { x: 30, y: 20 });
|
modeling.moveElements([ taskShape ], { x: 30, y: 20 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ describe('features/modeling - layout message flows', function() {
|
|||||||
messageFlowConnection = elementRegistry.get('MessageFlow_1');
|
messageFlowConnection = elementRegistry.get('MessageFlow_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ taskShape ], { x: 20, y: -20 });
|
modeling.moveElements([ taskShape ], { x: 20, y: -20 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ describe('features/modeling - layout message flows', function() {
|
|||||||
messageFlowConnection = elementRegistry.get('MessageFlow_5');
|
messageFlowConnection = elementRegistry.get('MessageFlow_5');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ participantShape ], { x: 100, y: 50 });
|
modeling.moveElements([ participantShape ], { x: 100, y: 50 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ describe('features/modeling - layout message flows', function() {
|
|||||||
messageFlowConnection = elementRegistry.get('MessageFlow_5');
|
messageFlowConnection = elementRegistry.get('MessageFlow_5');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([ participantShape ], { x: -200, y: 0 });
|
modeling.moveElements([ participantShape ], { x: -200, y: 0 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ describe('features/replace', function() {
|
|||||||
root = elementRegistry.get('Process_1');
|
root = elementRegistry.get('Process_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([startEvent], { x: 0, y: 200 }, root);
|
modeling.moveElements([startEvent], { x: 0, y: 200 }, root);
|
||||||
|
|
||||||
var startEventAfter = elementRegistry.filter(function(element) {
|
var startEventAfter = elementRegistry.filter(function(element) {
|
||||||
return is(element, 'bpmn:StartEvent') && element.parent === root;
|
return is(element, 'bpmn:StartEvent') && element.parent === root;
|
||||||
@ -752,7 +752,7 @@ describe('features/replace', function() {
|
|||||||
subProcess = elementRegistry.get('SubProcess_1');
|
subProcess = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([startEvent], { x: 260, y: 60 }, subProcess);
|
modeling.moveElements([startEvent], { x: 260, y: 60 }, subProcess);
|
||||||
|
|
||||||
var startEventAfter = elementRegistry.filter(function(element) {
|
var startEventAfter = elementRegistry.filter(function(element) {
|
||||||
return is(element, 'bpmn:StartEvent') && element.parent === subProcess;
|
return is(element, 'bpmn:StartEvent') && element.parent === subProcess;
|
||||||
@ -778,7 +778,7 @@ describe('features/replace', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([startEvent], { x: 260, y: 60 }, eventSubProcess);
|
modeling.moveElements([startEvent], { x: 260, y: 60 }, eventSubProcess);
|
||||||
|
|
||||||
var startEventAfter = elementRegistry.filter(function(element) {
|
var startEventAfter = elementRegistry.filter(function(element) {
|
||||||
return is(element, 'bpmn:StartEvent') && element.parent === eventSubProcess && element.type !== 'label';
|
return is(element, 'bpmn:StartEvent') && element.parent === eventSubProcess && element.type !== 'label';
|
||||||
@ -800,7 +800,7 @@ describe('features/replace', function() {
|
|||||||
var interruptingStartEvent = bpmnReplace.replaceElement(startEvent, { type: 'bpmn:StartEvent' });
|
var interruptingStartEvent = bpmnReplace.replaceElement(startEvent, { type: 'bpmn:StartEvent' });
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([interruptingStartEvent], { x: 0, y: 200 }, root);
|
modeling.moveElements([interruptingStartEvent], { x: 0, y: 200 }, root);
|
||||||
|
|
||||||
var startEventAfter = elementRegistry.filter(function(element) {
|
var startEventAfter = elementRegistry.filter(function(element) {
|
||||||
return is(element, 'bpmn:StartEvent') && element.parent === root;
|
return is(element, 'bpmn:StartEvent') && element.parent === root;
|
||||||
@ -838,7 +838,7 @@ describe('features/replace', function() {
|
|||||||
startEvent = elementRegistry.get('StartEvent_2');
|
startEvent = elementRegistry.get('StartEvent_2');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShapes([eventSubProcess], { x: 20, y: 30 });
|
modeling.moveElements([eventSubProcess], { x: 20, y: 30 });
|
||||||
|
|
||||||
// start event after moving parent
|
// start event after moving parent
|
||||||
var startEventAfter = elementRegistry.filter(function (element) {
|
var startEventAfter = elementRegistry.filter(function (element) {
|
||||||
|
@ -66,7 +66,7 @@ module.exports.appendShape = function(source, shape, distance, target, connectio
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports.moveShapes = function(elements, distance, target, isAttach, hints) {
|
module.exports.moveElements = function(elements, distance, target, isAttach, hints) {
|
||||||
|
|
||||||
var actualElements = elements.map(function(e) {
|
var actualElements = elements.map(function(e) {
|
||||||
var actualElement = getElement(e);
|
var actualElement = getElement(e);
|
||||||
@ -82,7 +82,7 @@ module.exports.moveShapes = function(elements, distance, target, isAttach, hints
|
|||||||
|
|
||||||
var delta = normalizeDelta(distance);
|
var delta = normalizeDelta(distance);
|
||||||
|
|
||||||
var allowed = rules.allowed('shapes.move', {
|
var allowed = rules.allowed('elements.move', {
|
||||||
shapes: actualElements,
|
shapes: actualElements,
|
||||||
delta: delta,
|
delta: delta,
|
||||||
target: target
|
target: target
|
||||||
@ -92,7 +92,7 @@ module.exports.moveShapes = function(elements, distance, target, isAttach, hints
|
|||||||
expect(allowed).to.eql(typeof isAttach === 'boolean' ? 'attach' : true);
|
expect(allowed).to.eql(typeof isAttach === 'boolean' ? 'attach' : true);
|
||||||
|
|
||||||
// perform actual move
|
// perform actual move
|
||||||
modeling.moveShapes(actualElements, delta, target, isAttach, hints);
|
modeling.moveElements(actualElements, delta, target, isAttach, hints);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user