-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modeling): disable autoResize for annotation changes
closes #2049
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import inherits from 'inherits-browser'; | ||
|
||
import { is } from '../../../util/ModelUtil'; | ||
|
||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; | ||
|
||
/** | ||
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus | ||
*/ | ||
|
||
export default function TextAnnotationBehavior(eventBus) { | ||
|
||
CommandInterceptor.call(this, eventBus); | ||
|
||
this.preExecute([ 'shape.create', 'shape.resize', 'elements.move' ], function(context) { | ||
const shapes = context.shapes || [ context.shape ]; | ||
|
||
if (shapes.length === 1 && is(shapes[0], 'bpmn:TextAnnotation')) { | ||
context.hints = context.hints || {}; | ||
|
||
context.hints.autoResize = false; | ||
} | ||
}, true); | ||
} | ||
|
||
inherits(TextAnnotationBehavior, CommandInterceptor); | ||
|
||
TextAnnotationBehavior.$inject = [ | ||
'eventBus' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/spec/features/modeling/behavior/TextAnnotationBehaviorSpec.bpmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0sumicc" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.19.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.4.0"> | ||
<bpmn:process id="Process_00kwner" isExecutable="true"> | ||
<bpmn:subProcess id="Subprocess_1"> | ||
<bpmn:task id="Task_1" /> | ||
<bpmn:textAnnotation id="TextAnnotation_1" /> | ||
</bpmn:subProcess> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_00kwner"> | ||
<bpmndi:BPMNShape id="Activity_0oq21yg_di" bpmnElement="Subprocess_1" isExpanded="true"> | ||
<dc:Bounds x="160" y="70" width="350" height="200" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="TextAnnotation_1beb5hp_di" bpmnElement="TextAnnotation_1"> | ||
<dc:Bounds x="380" y="80" width="100" height="30" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0stlo9y_di" bpmnElement="Task_1"> | ||
<dc:Bounds x="290" y="130" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
62 changes: 62 additions & 0 deletions
62
test/spec/features/modeling/behavior/TextAnnotationBehaviorSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
bootstrapModeler, | ||
inject | ||
} from 'test/TestHelper'; | ||
|
||
import modelingModule from 'lib/features/modeling'; | ||
import coreModule from 'lib/core'; | ||
import autoResizeModule from 'lib/features/auto-resize'; | ||
|
||
|
||
describe('features/modeling - TextAnnotationBehavior', function() { | ||
|
||
var testModules = [ coreModule, modelingModule, autoResizeModule ]; | ||
|
||
var processDiagramXML = require('./TextAnnotationBehaviorSpec.bpmn'); | ||
|
||
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules })); | ||
|
||
var annotation, | ||
task, | ||
subprocess; | ||
|
||
beforeEach(inject(function(elementRegistry) { | ||
annotation = elementRegistry.get('TextAnnotation_1'); | ||
task = elementRegistry.get('Task_1'); | ||
subprocess = elementRegistry.get('Subprocess_1'); | ||
})); | ||
|
||
|
||
it('should NOT resize Container on appending Text Annotation', inject(function(modeling) { | ||
|
||
// when | ||
modeling.appendShape(task, { type: 'bpmn:TextAnnotation' }); | ||
|
||
// then | ||
expect(subprocess.width).to.equal(350); | ||
expect(subprocess.height).to.equal(200); | ||
})); | ||
|
||
|
||
it('should NOT resize Container on Text Annotation resize', inject(function(modeling) { | ||
|
||
// when | ||
modeling.resizeShape(annotation, { x: 0, y: 0, width: 1000, height: 1000 }); | ||
|
||
// then | ||
expect(subprocess.width).to.equal(350); | ||
expect(subprocess.height).to.equal(200); | ||
})); | ||
|
||
|
||
it('should NOT resize Container on Text Annotation resize', inject(function(modeling) { | ||
|
||
// when | ||
modeling.moveShape(annotation, { x: 250, y: 250 }); | ||
|
||
// then | ||
expect(subprocess.width).to.equal(350); | ||
expect(subprocess.height).to.equal(200); | ||
})); | ||
|
||
}); |