Skip to content

Commit b32136b

Browse files
fix: ensure FEEL value is parsed when comparing changed properties
Related to camunda/camunda-modeler#4967
1 parent 8ffdb1e commit b32136b

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed

src/cloud-element-templates/Helper.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,25 @@ export function findZeebeSubscription(message) {
176176
return findExtension(message, 'zeebe:Subscription');
177177
}
178178

179-
export function getDefaultValue(property) {
180-
179+
/**
180+
* Get the default value disregarding generated values.
181+
*/
182+
export function getDefaultFixedValue(property) {
181183
if (
182184
shouldCastToFeel(property) || property.feel === 'required'
183185
) {
184186
return toFeelExpression(property.value, property.type);
185187
}
186188

187-
if (property.value !== undefined) {
188-
return property.value;
189+
return property.value;
190+
}
191+
192+
export function getDefaultValue(property) {
193+
194+
const value = getDefaultFixedValue(property);
195+
196+
if (value !== undefined) {
197+
return value;
189198
}
190199

191200
if (property.generatedValue) {

src/cloud-element-templates/cmd/ChangeElementTemplateHandler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import {
77
findExtension,
88
findMessage,
9+
getDefaultFixedValue,
910
getDefaultValue,
1011
getTemplateVersion,
1112
getTemplateId,
@@ -1705,7 +1706,7 @@ function shouldKeepValue(element, oldProperty, newProperty) {
17051706
* @returns {boolean}
17061707
*/
17071708
function propertyChanged(element, oldProperty) {
1708-
const oldPropertyValue = oldProperty.value;
1709+
const oldPropertyValue = getDefaultFixedValue(oldProperty);
17091710

17101711
return getPropertyValue(element, oldProperty) !== oldPropertyValue;
17111712
}

test/spec/cloud-element-templates/behavior/ConditionalBehavior.dependent-dropdowns.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,38 @@
8282
"constraints": {
8383
"notEmpty": true
8484
}
85+
},
86+
{
87+
"id": "feel-value",
88+
"label": "Broken FEEL",
89+
"feel": "required",
90+
"binding": {
91+
"name": "feel-value",
92+
"type": "property"
93+
},
94+
"condition": {
95+
"property": "root",
96+
"equals": "Root A",
97+
"type": "simple"
98+
},
99+
"type": "Text",
100+
"value": "broken"
101+
},
102+
{
103+
"id": "feel-value",
104+
"label": "Correct FEEL",
105+
"feel": "required",
106+
"binding": {
107+
"name": "feel-value",
108+
"type": "property"
109+
},
110+
"condition": {
111+
"property": "root",
112+
"equals": "Root B",
113+
"type": "simple"
114+
},
115+
"type": "Text",
116+
"value": "=correct"
85117
}
86118
]
87119
}

test/spec/cloud-element-templates/behavior/ConditionalBehavior.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,33 @@ describe('provider/cloud-element-templates - ConditionalBehavior', function() {
139139
);
140140

141141

142+
it('should update conditional feel property (missing equal sign)', inject(
143+
async function(modeling) {
144+
145+
// given
146+
const element = changeTemplate('Task_1', dependentDropdownsTemplate);
147+
const businessObject = getBusinessObject(element);
148+
149+
modeling.updateModdleProperties(element, businessObject, {
150+
root: 'Root A',
151+
});
152+
153+
// assume
154+
expect(businessObject.get('root')).to.eql('Root A');
155+
expect(businessObject.get('feel-value')).to.eql('=broken');
156+
157+
// when
158+
modeling.updateModdleProperties(element, businessObject, {
159+
root: 'Root B',
160+
});
161+
162+
// then
163+
expect(businessObject.get('root')).to.eql('Root B');
164+
expect(businessObject.get('feel-value')).to.eql('=correct');
165+
})
166+
);
167+
168+
142169
it('undo', inject(function(commandStack, modeling) {
143170

144171
// given

0 commit comments

Comments
 (0)