Skip to content

Commit

Permalink
fix: set $parent when creating task headers
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Oct 9, 2023
1 parent de8f01d commit daeefb2
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 @@ -438,7 +438,6 @@ export default class ChangeElementTemplateHandler {
return newBindingType === 'zeebe:taskHeader';
});


const businessObject = this._getOrCreateExtensionElements(element);

let taskHeaders = findExtension(businessObject, 'zeebe:TaskHeaders');
Expand All @@ -461,6 +460,8 @@ export default class ChangeElementTemplateHandler {
if (!taskHeaders) {
taskHeaders = bpmnFactory.create('zeebe:TaskHeaders');

taskHeaders.$parent = businessObject;

commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: businessObject,
Expand Down Expand Up @@ -502,6 +503,8 @@ export default class ChangeElementTemplateHandler {
else if (newPropertyValue) {
const newHeader = createTaskHeader(newBinding, newPropertyValue, bpmnFactory);

newHeader.$parent = taskHeaders;

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

expect(taskHeaders.$parent)
.to.equal(getBusinessObject(task).get('extensionElements'));

taskHeaders.get('zeebe:values').forEach((value) => {
expect(value.$parent).to.equal(taskHeaders);
});

expect(taskHeaders.get('zeebe:values')).to.jsonEqual([
{
$type: 'zeebe:Header',
Expand Down Expand Up @@ -918,6 +925,13 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
expect(taskHeaders).to.exist;
expect(taskHeaders.get('zeebe:values')).to.have.length(2);

expect(taskHeaders.$parent)
.to.equal(getBusinessObject(task).get('extensionElements'));

taskHeaders.get('zeebe:values').forEach((value) => {
expect(value.$parent).to.equal(taskHeaders);
});

expect(taskHeaders.get('zeebe:values')).to.jsonEqual([
{
$type: 'zeebe:Header',
Expand Down Expand Up @@ -949,6 +963,13 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
expect(taskHeaders).to.exist;
expect(taskHeaders.get('zeebe:values')).to.have.length(2);

expect(taskHeaders.$parent)
.to.equal(getBusinessObject(task).get('extensionElements'));

taskHeaders.get('zeebe:values').forEach((value) => {
expect(value.$parent).to.equal(taskHeaders);
});

expect(taskHeaders.get('zeebe:values')).to.jsonEqual([
{
$type: 'zeebe:Header',
Expand Down

0 comments on commit daeefb2

Please sign in to comment.