-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(space-tool): ensure minimum size when resizing shapes
- Loading branch information
1 parent
035bb0c
commit 7ee304f
Showing
5 changed files
with
117 additions
and
3 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
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,36 @@ | ||
import { forEach } from 'min-dash'; | ||
|
||
import { is } from '../../../util/ModelUtil'; | ||
|
||
import { isExpanded } from '../../../util/DiUtil'; | ||
|
||
import { | ||
PARTICIPANT_MIN_DIMENSIONS, | ||
SUB_PROCESS_MIN_DIMENSIONS, | ||
TEXT_ANNOTATION_MIN_DIMENSIONS | ||
} from './ResizeBehavior'; | ||
|
||
export default function SpaceToolBehavior(eventBus) { | ||
eventBus.on('spaceTool.getMinDimensions', function(context) { | ||
var shapes = context.shapes, | ||
minDimensions = {}; | ||
|
||
forEach(shapes, function(shape) { | ||
var id = shape.id; | ||
|
||
if (is(shape, 'bpmn:Participant')) { | ||
minDimensions[ id ] = PARTICIPANT_MIN_DIMENSIONS; | ||
} | ||
|
||
if (is(shape, 'bpmn:SubProcess') && isExpanded(shape)) { | ||
minDimensions[ id ] = SUB_PROCESS_MIN_DIMENSIONS; | ||
} | ||
|
||
if (is(shape, 'bpmn:TextAnnotation')) { | ||
minDimensions[ id ] = TEXT_ANNOTATION_MIN_DIMENSIONS; | ||
} | ||
}); | ||
|
||
return minDimensions; | ||
}); | ||
} |
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
13 changes: 13 additions & 0 deletions
13
test/spec/features/modeling/behavior/SpaceToolBehaviorSpec.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,13 @@ | ||
<?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" id="Definitions_1ev9p7s" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0"> | ||
<bpmn:process id="Process_1msk4wr" isExecutable="true"> | ||
<bpmn:subProcess id="SubProcess_1" /> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1msk4wr"> | ||
<bpmndi:BPMNShape id="SubProcess_04mmoqh_di" bpmnElement="SubProcess_1" isExpanded="true"> | ||
<dc:Bounds x="0" y="0" width="350" height="200" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
60 changes: 60 additions & 0 deletions
60
test/spec/features/modeling/behavior/SpaceToolBehaviorSpec.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,60 @@ | ||
import { | ||
bootstrapModeler, | ||
inject | ||
} from 'test/TestHelper'; | ||
|
||
import coreModule from 'lib/core'; | ||
import modelingModule from 'lib/features/modeling'; | ||
import rulesModule from 'lib/features/rules'; | ||
import snappingModule from 'lib/features/snapping'; | ||
import spaceToolModule from 'diagram-js/lib/features/space-tool'; | ||
|
||
import { | ||
createCanvasEvent as canvasEvent | ||
} from '../../../../util/MockEvents'; | ||
|
||
import { SUB_PROCESS_MIN_DIMENSIONS } from 'lib/features/modeling/behavior/ResizeBehavior'; | ||
|
||
var testModules = [ | ||
coreModule, | ||
modelingModule, | ||
rulesModule, | ||
snappingModule, | ||
spaceToolModule | ||
]; | ||
|
||
|
||
describe('features/modeling - space tool behavior', function() { | ||
|
||
describe('participant', function() { | ||
|
||
describe('minimum dimensions', function() { | ||
|
||
var diagramXML = require('./SpaceToolBehaviorSpec.bpmn'); | ||
|
||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); | ||
|
||
|
||
it('should ensure minimum dimensions', inject( | ||
function(dragging, elementRegistry, spaceTool) { | ||
|
||
// given | ||
var subProcess = elementRegistry.get('SubProcess_1'); | ||
|
||
// when | ||
spaceTool.activateMakeSpace(canvasEvent({ x: 300, y: 0 })); | ||
|
||
dragging.move(canvasEvent({ x: 0, y: 0 })); | ||
|
||
dragging.end(); | ||
|
||
// then | ||
expect(subProcess.width).to.equal(SUB_PROCESS_MIN_DIMENSIONS.width); | ||
}) | ||
); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |