From 0393d518930088e0e5e2d07379a341784d0576a1 Mon Sep 17 00:00:00 2001 From: hoferch91 Date: Thu, 3 Mar 2016 17:51:07 +0100 Subject: [PATCH] chore(modeling): set minimum height to one line Closes #402 --- lib/features/modeling/ElementFactory.js | 4 ++++ lib/features/snapping/BpmnSnapping.js | 4 ++-- .../features/modeling/append/TextAnnotationSpec.js | 13 +++++++++++++ .../modeling/layout/LayoutAssociationSpec.js | 6 +++--- test/spec/features/snapping/BpmnSnappingSpec.js | 2 +- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js index 8719e400..a1a5f83c 100644 --- a/lib/features/modeling/ElementFactory.js +++ b/lib/features/modeling/ElementFactory.js @@ -155,6 +155,10 @@ ElementFactory.prototype._getDefaultSize = function(semantic) { return { width: 50, height: 50 }; } + if (is(semantic, 'bpmn:TextAnnotation')) { + return { width: 100, height: 30 }; + } + return { width: 100, height: 80 }; }; diff --git a/lib/features/snapping/BpmnSnapping.js b/lib/features/snapping/BpmnSnapping.js index 3d046a5d..e47f0ddb 100644 --- a/lib/features/snapping/BpmnSnapping.js +++ b/lib/features/snapping/BpmnSnapping.js @@ -234,7 +234,7 @@ function BpmnSnapping(eventBus, canvas, bpmnRules, elementRegistry) { } if (is(shape, 'bpmn:TextAnnotation')) { - context.minDimensions = { width: 50, height: 50 }; + context.minDimensions = { width: 50, height: 30 }; } }); @@ -455,4 +455,4 @@ function snapBoundaryEvent(event, shape, target) { if (/right/.test(direction)) { setSnapped(event, 'x', targetTRBL.right); } -} \ No newline at end of file +} diff --git a/test/spec/features/modeling/append/TextAnnotationSpec.js b/test/spec/features/modeling/append/TextAnnotationSpec.js index 3c2a1a05..cf7402b7 100644 --- a/test/spec/features/modeling/append/TextAnnotationSpec.js +++ b/test/spec/features/modeling/append/TextAnnotationSpec.js @@ -85,9 +85,22 @@ describe('features/modeling - append text-annotation', function() { expect(connecting.$parent.id).to.equal('Transaction_2'); })); + it('with right size', inject(function(elementRegistry, elementFactory, modeling) { + + //given + var eventShape = elementRegistry.get('IntermediateCatchEvent_1'); + + //when + var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }); + + //then + expect(annotationShape.width).to.eql(100); + expect(annotationShape.height).to.eql(30); + })); }); + describe('undo', function() { it('should undo wire connection source + target', inject(function(elementRegistry, modeling, commandStack) { diff --git a/test/spec/features/modeling/layout/LayoutAssociationSpec.js b/test/spec/features/modeling/layout/LayoutAssociationSpec.js index d1bc370b..20b7acb8 100644 --- a/test/spec/features/modeling/layout/LayoutAssociationSpec.js +++ b/test/spec/features/modeling/layout/LayoutAssociationSpec.js @@ -35,7 +35,7 @@ describe('features/modeling - layout association', function() { // then expect(waypoints).to.eql([ - { original: { x: 400, y: 400 }, x: 370, y: 360 }, + { original: { x: 400, y: 400 }, x: 389, y: 385 }, { original: { x: 191, y: 120 }, x: 202, y: 134 } ]); @@ -57,7 +57,7 @@ describe('features/modeling - layout association', function() { // then expect(waypoints).to.eql([ - { original: { x: 420, y: 400 }, x: 387, y: 360 }, + { original: { x: 420, y: 400 }, x: 408, y: 385 }, { original: { x: 191, y: 120 }, x: 202, y: 134 } ]); @@ -85,7 +85,7 @@ describe('features/modeling - layout association', function() { // then expect(waypoints).to.eql([ - { original: { x: 420, y: 400 }, x: 412, y: 360 }, + { original: { x: 420, y: 400 }, x: 417, y: 385 }, { x: 400, y: 300 }, { original: { x: 191, y: 120 }, x: 204, y: 131 } ]); diff --git a/test/spec/features/snapping/BpmnSnappingSpec.js b/test/spec/features/snapping/BpmnSnappingSpec.js index e8f0ed16..3cb5c76a 100644 --- a/test/spec/features/snapping/BpmnSnappingSpec.js +++ b/test/spec/features/snapping/BpmnSnappingSpec.js @@ -416,7 +416,7 @@ describe('features/snapping - BpmnSnapping', function() { dragging.end(); expect(textAnnotation.width).to.equal(50); - expect(textAnnotation.height).to.equal(50); + expect(textAnnotation.height).to.equal(30); })); });