Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(outline): external label resize #2003

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/features/outline/OutlineProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ OutlineProvider.prototype.getOutline = function(element) {
*/
OutlineProvider.prototype.updateOutline = function(element, outline) {

if (isLabel(element)) {
return;
}

if (isAny(element, [ 'bpmn:SubProcess', 'bpmn:Group' ])) {

svgAttr(outline, {
Expand Down
11 changes: 7 additions & 4 deletions test/spec/features/outline/OutlineProvider.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<bpmn:dataObject id="DataObject_0usa0me" />
<bpmn:dataStoreReference id="DataStore" />
<bpmn:subProcess id="SubProcess">
<bpmn:startEvent id="Event" />
<bpmn:startEvent id="Event" name="label" />
<bpmn:task id="Task" />
<bpmn:exclusiveGateway id="Gateway" />
</bpmn:subProcess>
Expand All @@ -30,13 +30,16 @@
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0dihp8i_di" bpmnElement="Event">
<dc:Bounds x="460" y="322" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0px6pz2_di" bpmnElement="Gateway" isMarkerVisible="true">
<dc:Bounds x="665" y="315" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="466" y="365" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0b3cy2o_di" bpmnElement="Task">
<dc:Bounds x="530" y="300" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0px6pz2_di" bpmnElement="Gateway" isMarkerVisible="true">
<dc:Bounds x="665" y="315" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_1utiosm_di" bpmnElement="Group">
<dc:Bounds x="200" y="179" width="140" height="300" />
</bpmndi:BPMNShape>
Expand Down
40 changes: 34 additions & 6 deletions test/spec/features/outline/OutlineProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
DATA_STORE_REFERENCE_OUTLINE_PATH
} from 'lib/features/outline/OutlineUtil';

import {
query as domQuery
} from 'min-dom';

describe('features/outline - outline provider', function() {
var testModules = [
Expand Down Expand Up @@ -118,17 +121,44 @@ describe('features/outline - outline provider', function() {

describe('update', function() {

describe('should update label', function() {

var DELTA = 3;

it('should update label according to label dimentions', inject(function(elementRegistry, selection, modeling) {

// given
var event = elementRegistry.get('Event');
var externalLabel = event.label;

selection.select(externalLabel);
var outlineShape = domQuery('.selected .djs-outline', outlineShape);

// then
let bounds = outlineShape.getBoundingClientRect();
expect(bounds.width).to.be.closeTo(34, DELTA);
expect(bounds.height).to.be.closeTo(24, DELTA);

// when
modeling.updateLabel(externalLabel, 'fooooooooooooooo');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this test case :D


// then
bounds = outlineShape.getBoundingClientRect();
expect(bounds.width).to.be.closeTo(93, DELTA);
expect(bounds.height).to.be.closeTo(37, DELTA);
}));

});


describe('should update dimensions on resize', function() {

it('sub process', inject(function(elementRegistry, outline, selection, modeling) {
it('sub process', inject(function(elementRegistry, outline, modeling) {

// given
var subProcess = elementRegistry.get('SubProcess');
var outlineShape = outline.getOutline(subProcess);

selection.select(subProcess);

// when
modeling.resizeShape(subProcess, { x: 339, y: 142, width: 250, height: 250 });
outline.updateShapeOutline(outlineShape, subProcess);
Expand All @@ -139,14 +169,12 @@ describe('features/outline - outline provider', function() {
}));


it('group', inject(function(elementRegistry, outline, selection, modeling) {
it('group', inject(function(elementRegistry, outline, modeling) {

// given
var group = elementRegistry.get('Group');
var outlineShape = outline.getOutline(group);

selection.select(group);

// when
modeling.resizeShape(group, { x: 339, y: 142, width: 250, height: 250 });
outline.updateShapeOutline(outlineShape, group);
Expand Down