Skip to content

Commit

Permalink
feat(element-templates): make zeebe:property optional
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme authored and fake-join[bot] committed Sep 1, 2022
1 parent 93aeee7 commit f85db35
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ export default class ChangeElementTemplateHandler {

// (2) update old zeebe:Property
if (oldZeebeProperty) {
if (shouldUpdate(newPropertyValue, newProperty)
|| shouldKeepValue(oldZeebeProperty, oldProperty, newProperty)) {
remove(oldZeebeProperties, oldZeebeProperty);
}

if (!shouldKeepValue(oldZeebeProperty, oldProperty, newProperty)) {
commandStack.execute('element.updateModdleProperties', {
Expand All @@ -572,12 +576,10 @@ export default class ChangeElementTemplateHandler {
}
});
}

remove(oldZeebeProperties, oldZeebeProperty);
}

// (3) add new zeebe:Property
else {
else if (shouldUpdate(newPropertyValue, newProperty)) {
const newProperty = createZeebeProperty(newBinding, newPropertyValue, bpmnFactory);

commandStack.execute('element.updateModdleProperties', {
Expand Down
10 changes: 7 additions & 3 deletions src/provider/cloud-element-templates/util/propertyUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,17 +371,21 @@ export function setPropertyValue(bpmnFactory, commandStack, element, property, v

const oldZeebeProperty = findZeebeProperty(zeebeProperties, binding);

const newZeebeProperty = createZeebeProperty(binding, value, bpmnFactory);

const properties = zeebeProperties.get('properties').filter((property) => property !== oldZeebeProperty);

if (shouldUpdate(value, property)) {
const newZeebeProperty = createZeebeProperty(binding, value, bpmnFactory);

properties.push(newZeebeProperty);
}

commands.push({
cmd: 'element.updateModdleProperties',
context: {
element,
moddleElement: zeebeProperties,
properties: {
properties: [ ...properties, newZeebeProperty ]
properties
}
}
});
Expand Down
Loading

0 comments on commit f85db35

Please sign in to comment.