Skip to content

Commit

Permalink
fix: set $parent when creating message
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Oct 9, 2023
1 parent 7a1e283 commit 5a7d9ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/cloud-element-templates/cmd/ChangeElementTemplateHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import {
MESSAGE_PROPERTY_TYPE,
MESSAGE_ZEEBE_SUBSCRIPTION_PROPERTY_TYPE
} from '../util/bindingTypes';
import { createElement } from '../../utils/ElementUtil';

import {
createElement,
getRoot
} from '../../utils/ElementUtil';

/**
* Applies an element template to an element. Sets `zeebe:modelerTemplate` and
Expand Down Expand Up @@ -654,6 +658,7 @@ export default class ChangeElementTemplateHandler {
}

const message = this._getOrCreateMessage(element, newTemplate);

newProperties.forEach((newProperty) => {
const oldProperty = findOldProperty(oldTemplate, newProperty),
newBinding = newProperty.binding,
Expand Down Expand Up @@ -762,6 +767,8 @@ export default class ChangeElementTemplateHandler {
if (!message) {
message = this._bpmnFactory.create('bpmn:Message', { 'zeebe:modelerTemplate': template.id });

message.$parent = getRoot(bo);

this._modeling.updateModdleProperties(element, bo, { messageRef: message });
}

Expand Down Expand Up @@ -1091,4 +1098,4 @@ function remove(array, item) {
array.splice(index, 1);

return array;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
const newTemplate = require('./event-template-1.json');


it('execute', inject(function(elementRegistry) {
it('execute', inject(function(bpmnjs, elementRegistry) {

// given
let event = elementRegistry.get('Event_1');
Expand All @@ -1515,6 +1515,8 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(

expect(message).to.exist;
expect(message.get('name')).to.equal('name');

expect(message.$parent).to.equal(bpmnjs.getDefinitions());
}));


Expand All @@ -1537,7 +1539,7 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
}));


it('redo', inject(function(commandStack, elementRegistry) {
it('redo', inject(function(bpmnjs, commandStack, elementRegistry) {

// given
let event = elementRegistry.get('Event_1');
Expand All @@ -1555,7 +1557,10 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(

expect(message).to.exist;
expect(message.get('name')).to.equal('name');

expect(message.$parent).to.equal(bpmnjs.getDefinitions());
}));

});


Expand Down

0 comments on commit 5a7d9ad

Please sign in to comment.