Skip to content

Commit

Permalink
fix: set $parent when creating properties
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Oct 9, 2023
1 parent daeefb2 commit 7a1e283
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ export default class ChangeElementTemplateHandler {
if (!zeebeProperties) {
zeebeProperties = bpmnFactory.create('zeebe:Properties');

zeebeProperties.$parent = businessObject;

commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: businessObject,
Expand Down Expand Up @@ -608,6 +610,8 @@ export default class ChangeElementTemplateHandler {
else if (shouldUpdate(newPropertyValue, newProperty)) {
const newProperty = createZeebeProperty(newBinding, newPropertyValue, bpmnFactory);

newProperty.$parent = zeebeProperties;

commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: zeebeProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,13 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
expect(zeebeProperties).to.exist;
expect(zeebeProperties.get('properties')).to.have.length(2);

expect(zeebeProperties.$parent)
.to.equal(getBusinessObject(serviceTask).get('extensionElements'));

zeebeProperties.get('properties').forEach((property) => {
expect(property.$parent).to.equal(zeebeProperties);
});

expect(zeebeProperties.get('properties')).to.jsonEqual([
{
$type: 'zeebe:Property',
Expand Down Expand Up @@ -1268,6 +1275,13 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
expect(zeebeProperties).to.exist;
expect(zeebeProperties.get('properties')).to.have.length(2);

expect(zeebeProperties.$parent)
.to.equal(getBusinessObject(serviceTask).get('extensionElements'));

zeebeProperties.get('properties').forEach((property) => {
expect(property.$parent).to.equal(zeebeProperties);
});

expect(zeebeProperties.get('properties')).to.jsonEqual([
{
$type: 'zeebe:Property',
Expand Down Expand Up @@ -1299,6 +1313,13 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
expect(zeebeProperties).to.exist;
expect(zeebeProperties.get('properties')).to.have.length(2);

expect(zeebeProperties.$parent)
.to.equal(getBusinessObject(serviceTask).get('extensionElements'));

zeebeProperties.get('properties').forEach((property) => {
expect(property.$parent).to.equal(zeebeProperties);
});

expect(zeebeProperties.get('properties')).to.jsonEqual([
{
$type: 'zeebe:Property',
Expand Down Expand Up @@ -1442,7 +1463,6 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
});



describe('zeebe:Property not specified', function() {

const newTemplate = require('./task-template-no-properties.json');
Expand Down

0 comments on commit 7a1e283

Please sign in to comment.