feat(replace): focus element after replace

Related to #192
This commit is contained in:
Nico Rehwaldt 2015-03-11 16:31:42 +01:00
parent 67d81c346c
commit 1c0ade9d51
3 changed files with 28 additions and 3 deletions

View File

@ -21,7 +21,7 @@ var startEventReplace = REPLACE_OPTIONS.START_EVENT,
* @param {PopupMenu} popupMenu
* @param {Replace} replace
*/
function BpmnReplace(bpmnFactory, moddle, popupMenu, replace) {
function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection) {
/**
* Prepares a new business object for the replacement element
@ -71,7 +71,11 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace) {
// TODO: copy other elligable properties from old business object
businessObject.name = oldBusinessObject.name;
return replace.replaceElement(element, newElement);
newElement = replace.replaceElement(element, newElement);
selection.select(newElement);
return newElement;
}
@ -165,6 +169,6 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace) {
this.replaceElement = replaceElement;
}
BpmnReplace.$inject = [ 'bpmnFactory', 'moddle', 'popupMenu', 'replace' ];
BpmnReplace.$inject = [ 'bpmnFactory', 'moddle', 'popupMenu', 'replace', 'selection' ];
module.exports = BpmnReplace;

View File

@ -2,6 +2,7 @@ module.exports = {
__depends__: [
require('diagram-js/lib/features/popup-menu'),
require('diagram-js/lib/features/replace'),
require('diagram-js/lib/features/selection'),
require('../modeling')
],
bpmnReplace: [ 'type', require('./BpmnReplace') ]

View File

@ -85,6 +85,26 @@ describe('features/replace', function() {
});
describe('selection', function() {
it('should select after replace', inject(function(elementRegistry, selection, bpmnReplace) {
// given
var task = elementRegistry.get('Task_1');
var newElementData = {
type: 'bpmn:UserTask'
};
// when
var newElement = bpmnReplace.replaceElement(task, newElementData);
// then
expect(selection.get()).toContain(newElement);
}));
});
describe('label', function() {
it('should keep copy label', inject(function(elementRegistry, bpmnReplace) {