Skip to content

Commit

Permalink
feat(drd): activate direct editing after text annotation create
Browse files Browse the repository at this point in the history
Closes #185
  • Loading branch information
Niklas Kiefer authored and fake-join[bot] committed Mar 9, 2020
1 parent a4078d4 commit 1e2ae73
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ export default function LabelEditingProvider(

var element = e.shape;

if (is(element, 'dmn:Decision') || is(element, 'dmn:InputData') ||
is(element, 'dmn:BusinessKnowledgeModel') || is(element, 'dmn:KnowledgeSource')) {

if (
is(element, 'dmn:Decision') ||
is(element, 'dmn:InputData') ||
is(element, 'dmn:BusinessKnowledgeModel') ||
is(element, 'dmn:KnowledgeSource') ||
is(element, 'dmn:TextAnnotation')
) {
directEditing.activate(element);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import {
bootstrapViewer,
bootstrapModeler,
inject
} from 'test/TestHelper';

import labelEditingModule from 'src/features/label-editing';
import modelingModule from 'src/features/modeling';
import coreModule from 'src/core';
import createModule from 'diagram-js/lib/features/create';
import draggingModule from 'diagram-js/lib/features/dragging';

import {
getLabel
} from 'src/features/label-editing/LabelUtil';

import {
createCanvasEvent as canvasEvent
} from 'test/util/MockEvents';


function triggerKeyEvent(element, event, code) {
var e = document.createEvent('Events');
Expand All @@ -30,9 +35,15 @@ describe('features - label-editing', function() {

var diagramXML = require('../../../fixtures/dmn/di.dmn');

var testModules = [ labelEditingModule, coreModule, draggingModule, modelingModule ];
var testModules = [
modelingModule,
labelEditingModule,
coreModule,
createModule,
draggingModule
];

beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));

var setText;

Expand Down Expand Up @@ -223,4 +234,81 @@ describe('features - label-editing', function() {

});

describe('after create', function() {

var createElement;

beforeEach(inject(
function(canvas, create, dragging, elementFactory, elementRegistry) {

createElement = function(type) {

var shape = elementFactory.create('shape', { type: type }),
parent = canvas.getRootElement(),
parentGfx = elementRegistry.getGraphics(parent);

create.start(canvasEvent({ x: 0, y: 0 }), shape);

dragging.hover({
element: parent,
gfx: parentGfx
});

dragging.move(canvasEvent({ x: 400, y: 250 }));
dragging.end();
};
}
));

it('should activate on Decision', inject(function(directEditing) {

// when
createElement('dmn:Decision');

// then
expect(directEditing.isActive()).to.be.true;
}));


it('should activate on InputData', inject(function(directEditing) {

// when
createElement('dmn:InputData');

// then
expect(directEditing.isActive()).to.be.true;
}));


it('should activate on BusinessKnowledgeModel', inject(function(directEditing) {

// when
createElement('dmn:BusinessKnowledgeModel');

// then
expect(directEditing.isActive()).to.be.true;
}));


it('should activate on KnowledgeSource', inject(function(directEditing) {

// when
createElement('dmn:KnowledgeSource');

// then
expect(directEditing.isActive()).to.be.true;
}));


it('should activate on TextAnnotation', inject(function(directEditing) {

// when
createElement('dmn:TextAnnotation');

// then
expect(directEditing.isActive()).to.be.true;
}));

});

});

0 comments on commit 1e2ae73

Please sign in to comment.